Poor quality code produced by uiBinder when using CSSResources

51 views
Skip to first unread message

Paul Stockley

unread,
Dec 17, 2011, 9:28:19 AM12/17/11
to google-we...@googlegroups.com
I use a lot of HTML panels so I can use native html for as much layout and styling as possible for performance reasons. I try and minimize the number of widgets I use which is especially helpful on mobile devices. As a result, I use quite a lot of css class references to either local uibinder styles or styles defined in a global application css resource. The problem is that it results in JS code such as the following:

f_HTMLPanel1 = new HTMLPanel_0((sb_2 = new StringBuilder_0 , sb_2.impl.string += "<span id='" , $append_6(sb_2, htmlEscape(domId0)) , sb_2.impl.string += "'><\/span> <div class='" , $append_6(sb_2, htmlEscape('GKOWVOJDGN')) , sb_2.impl.string += "'> <div class='" , $append_6(sb_2, htmlEscape('GKOWVOJDHN')) , sb_2.impl.string += "'> <span id='" , $append_6(sb_2, htmlEscape(domId1)) , sb_2.impl.string += "'><\/span> <span id='" , $append_6(sb_2, htmlEscap

The obfuscated class names are clearly static and known at compile time and I would expect them to be inlined in the strings e.g.

<\/span> <div class=''GKOWVOJDGN'....

One of the proposed benefits of using a css resource is shorter class names, However, In reality I would be better of using styles directly loaded in my startup page. The net result is that there are far to many string concatenations and code bloat. This really adds up on a large project and especially hurts when building things like iPad applications.  

Vitrums

unread,
Dec 19, 2011, 6:05:31 PM12/19/11
to google-we...@googlegroups.com
That doesn't even look so hurtful as you describe it. Needless to say, modern smartphones would handle such kind of scripts easily without noticeable delay. Consider profiling your app with the Speed Tracer to make this discussion more meaningful. Also consider the compiler flag -XdisableClassMetadata to feel the real power of class obfuscation ^^

Paul Stockley

unread,
Dec 20, 2011, 11:16:54 AM12/20/11
to google-we...@googlegroups.com
That isn't the case, I can tell a measurable difference. This change was introduced when uiBinder switched to use SafeHTMLTemplates. You can use the following to disable its use

<set-configuration-property name="UiBinder.useSafeHtmlTemplates" value="false"/>

In a more extreme example, I was using a SafeHTMLTemplates to build a complex list and just the class names resulted in 1000 extra string concatenations. This resulted in easily a second delay. When you are trying to build web apps that are as responsive as native apps this is unacceptable. The fix was to abandon the template and build the string myself and just escape the fields that contained data from the server.
Reply all
Reply to author
Forward
0 new messages