Mike
Mike

Reputation: 3575

GWT code-split: Common widget will go to leftover, any way to prevent?

My GWT application has a navigation bar, which includes 3 views: Home view and View1, View2, View1 and View2 are controlled by their activities, and both use a same widget(they new the widget each under their constructor). When the app first launched, it will go to home page.

When doing code split, i found that the common widget is included in leftover segment, but i wish it could be downloaded only when user click view1 or view2, not in leftover, any way to achieve this?

Thanks.

Upvotes: 0

Views: 246

Answers (2)

Andrei Volgin
Andrei Volgin

Reputation: 41089

If your users are very likely to go to either View 1 or View 2, you may be better off keeping this widget in a leftover fragment. It won't slow down the initial rendering of the app, and the leftover code will load while a user thinks where to go next. By the time a user clicks on View 1 or View 2, the widget will be already loaded.

In most cases the compiler is not going to merge View 1 and View 2 fragments unless they share a lot of code, not just one widget, although you can force the compiler to be more aggressive in merging by reducing the number of desired fragments.

Upvotes: 1

Mike
Mike

Reputation: 3575

Aha, just after i post this thread, i found https://developers.google.com/web-toolkit/articles/fragment_merging which totally address my question. It's GWT 2.5 new feature.

Upvotes: 0

Related Questions