There's no Code Splitting option When I create PresenterWidget
in Eclipse, so I assume that my PresenterWidget
or DialogBox
(that is initiated in HeaderPresenter
) will be downloaded at the time the HeaderPresenter
is called.
Let see this code in HeaderPresenter
:
Button b = new Button("Click me", new ClickHandler() {
public void onClick(ClickEvent event) {
MyDialogBox myD=new MyDialogBox(); ///There a lot of Gui (button, grid, css...) on this dialogbox
myD.show();
}
});
So, my first question is:
1st, Will the webapp download all the GUI of MyDialogBox
when user comes to page Header
?
2nd, Suppose users come to page Header
second time on the same browser & also the SAME session, then will the webapp download all the GUI of MyDialogBox
? (if it is on the same session, then i believe it won't download again since the GUI got Catch elsewhere)
Ok, now I will put this Code Splitting as suggested by Google http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html, as following:
Button b = new Button("Click me", new ClickHandler() {
public void onClick(ClickEvent event) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert("Code download failed");
}
public void onSuccess() {
MyDialogBox myD=new MyDialogBox(); ///There a lot of Gui (button, grid, css...) on this dialogbox
myD.show();
}
});
}
});
My assumption is that the Webapp will not download this code whenever user visits Header
page. But it will download the code on when users click the button "b". But my question is that
If you click the button first time, then it will download, but what if user clicks the same button 2nd time or even 3rd time, then will the app continue to download the same GUI
of DialogBox
in 2nd/3rd time? or Will the app catch the GUI
of the DialogBox
elsewhere when it downloaded 1st time & when user clicks 2nd/3rd time it will recall the catch rather than downloading the same things again?
I am confused, can anyone clarify?
Also, is it worthy to do code splitting for big DialogBox
?