From 59db6f1bfada0f4ccd5f90ed7cd27f736856d9f0 Mon Sep 17 00:00:00 2001 From: Mikael Grankvist Date: Mon, 27 Mar 2023 15:03:34 +0300 Subject: [PATCH 1/7] fix: Lazy init of disable on click Only init disable on click if actually enabled for button. Move function to buttonFunctions.js so each button only needs to call the function. Moving function makes 5000 buttons request 0.5 MB smaller and lazy init to only calll method for disbleOnClick buttons drops 1MB from the request. --- .../vaadin/flow/component/button/Button.java | 20 ++++++++++++++----- .../resources/frontend/buttonFunctions.js | 10 ++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 vaadin-button-flow-parent/vaadin-button-flow/src/main/resources/META-INF/resources/frontend/buttonFunctions.js diff --git a/vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/Button.java b/vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/Button.java index 9dbfee9d053..d7c463103fa 100644 --- a/vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/Button.java +++ b/vaadin-button-flow-parent/vaadin-button-flow/src/main/java/com/vaadin/flow/component/button/Button.java @@ -57,6 +57,7 @@ @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @NpmPackage(value = "@vaadin/button", version = "24.1.0-alpha5") @JsModule("@vaadin/button/src/vaadin-button.js") +@JsModule("./buttonFunctions.js") public class Button extends Component implements ClickNotifier