Optimize GWT performance

Apr 02
2013

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. :D

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

RoboCode

Feb 07
2013

robocode

Today I learned about Robo Code.

It’s a fun game allowing you to write an algorithm for a moving an shooting little tank.

The tank then fights one of your friends algorithm / tank. :)

Two interesting videos that combine RoboCode with genetic algorithms and reinforced learning, after the break :)
Read the rest of this entry »

Java Fitness / Challenges

Feb 07
2013

It turns out, there are quite a few places on the web to practice your Java skill level.

First I found out about http://codeeval.com/ .

I tried to do a puzzle just for fun and to see how the site is (code is not optimized or anything, just trying out their UI) :).

At the end there are some screenshots.

Read the rest of this entry »

The future of GWT report

Feb 05
2013

At the below link you can read a very interesting report about the future of GWT.
https://vaadin.com/gwt/report-2012

I’ll write another post with opinions if I have any (or time :) ).

ClassNotFoundException: com.google.gwt.core.client.GWTBridge

Jan 17
2013

This post will explain the cause of this exception and provide an easy fix - with no need to add extra jars to your classpath or manually manipulate your jars.

I first saw this exception when I upgraded a project from GWT 2.4 to GWT 2.5.

The project also uses GXT 2 and 3 running side by side.

After the upgrade I saw this in the logs:

…………..

Caused by: java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge
at com.extjs.gxt.ui.client.core.FastMap.<init>(FastMap.java:139)
at com.extjs.gxt.ui.client.data.RpcMap.<init>(RpcMap.java:69)
at com.extjs.gxt.ui.client.data.BaseModelData.set(BaseModelData.java:125)
at com.extjs.gxt.ui.client.data.BaseModel.set(BaseModel.java:143)
…………..

Read the rest of this entry »