Optimize GWT performance

It depends on what you are looking to optimize. This article will give some advice concerning – compile time, initial download, and runtime performance.

If compilation takes too much time, you could have different configurations, one for continuous build, one for nightly / automated testing and another for production.
Here’s a link with more details on how to customize the GWT Compiler.

If the initial download of the application is too large, you can check if you are using Code Splitting, a feature that allows the application GWT to start  running after it downloaded a part of the code, while other parts of the code will be downloaded as they are needed. More details here. You can see quickly if it is used or not in the compile report.

If the application is slow at runtime (if it takes long between when you press a button and the action happens), maybe there are too many elements in the DOM. For example if you have a tab panel with complicated UI in each tab, if a tab is not selected, you can remove it from the DOM, and the rest of the application will run faster. (Save it’s index to insert it back in the same place when you need it).

protected void detach (Widget child) {
child.getElement (). removeFromParent ();

protected void attach (Widget child, int beforeIndex) {
getElement (). insertChild (child.getElement (), beforeIndex);

Depending on what libraries you use, they can also slow your app down. Standard GWT is pretty fast, libraries (like GXT that I use also :D) will definitely slow down your app.
Of course it depends on which libraries, and how well they are written. For example mGWT will not make your app slower :).

GWT has several options to optimize the compiler (by modifying the  gwt.xml file), for example:

<! – Smaller JS file ->
<set-property name=”compiler.stackMode” value=”strip” />
<set-configuration-property name=”CssResource.obfuscationPrefix” value=”empty” />

Also make sure the production build does not have this tag in gwt.xml:

<inherits name=”com.google.gwt.user.Debug”/>

because it will run slower. 😀

There are definitely other optimizations. Add a comment if you have anything to add here :).