GWT applications sometimes are a bit heavy in terms of bandwidth usage; because they go over 300KBs, which is too much for some users. Fortunately there are several things that can be done to reduce the size. First technique really kicks a**.
Turn on Browser Compression (70% size reduction)
You can force the server to pack some files, which are requested by a browser. If you turn on gzip packing for javascript, html and css content, you will get spectacular size reduction. If you keep your application on:
- Apache, read this.
- Tomcat users need to open server.xml, find connector element, and add an attribute: Compression="on".
- Jboss users also need to change server.xml, which is located in
JBOSS_HOME/server/default/deploy/jboss-web.deployer,
they also need to find Connector Element and add an attribute compression="force"
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192" emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="force"/>
WARNING! GWT apps are designed for borwsers which support compresion, but in general not all browsers support compression (IE5).
Compile using obfuscated output
GWT compiler uses very simple and short variable names instead of those used by Developers. There is also a positive side effect of this mathod, stealing/understanding of our code will be very dificult.
Use Implementations instead of Interfaces
For example use an ArrayLists instead of Lists, then GWT compiler does not need to prepare the code for all possible implementations of the List. I heard about this method in a very interesting Google I/O presentation by Ray Rayan.
Splitting code
If we reach the limits of reducing applications size, we can try to split the application. This allows doing some lazy loading of some modules. Here you can read how to do it. It's not an easy task, I would say it is a kind of art :).
WARNING! In current version GWT 2.0 Splitting cannot be used together with cross site linking (<add-linker name="xs"/>).
Image bundles and caching files for ever
This techniques are described in this article by Ryan Dewsbury.
If you know some other size reduction techniques, I would be glad if you would share them with us.




