On a Google IO Talk it was mentioned that widgets make your apps run slow and you should avoid them at all cost. But I would like to use the gwt-bootstrap
widget library. This would pollute my ui.xml with a lot of widgets.
The reason I use this library and not the standard gwt bootstrap.js file, is because I don't want to include the library nor do I want to use the customize option of bootstrap. The reason would be the large initial download and the annoyance of having to be aware of possible missing features when added code to the UI.
So my questions are:
- Do the widgets slow down the app significantly?
- What number of widgets should be fine?
In the google IO talk they had a max of around 10, I don't remember well.
It depends. It depends whether you make a mobile app, whether you care about old browsers (IE8, I'm looking at you), etc.
Widgets within a composite widget? widgets displayed at the same time on the screen? Widgets within the whole app?
We use tens of widgets and I don't think they slow us down (server side and moving data across the wire are what take most of the time, not the client side). But our lowest-level widgets, among the ones that we reuse the most, and sometimes a bit complex, aren't (all) composites, and use event delegation.
My rule of thumb is: if an
Element
is enough (such as aSpanElement
to display some data, or anInputElement
for a textbox where you don't care about events), then use it. If you need events, then use a widget. The exception to the rule is if you're building a reusable complex widget and using event delegation wouldn't add too much complexity to it compare to composing widgets.Remember: premature optimization is the root of all evil, and the 3 rules of performance are measure, measure, measure.
BTW, your reasons for using gwt-bootstrap rather than bootstrap.js are misinformed: gwt-boostrap loads bootstrap.js like you could do it yourself, and thus won't save you from that large initial download.