Skip to content

Finding supported GWT user.agent values

The GWT compile process has been taking longer and longer, as I’ve moved from 1.0 to 2.0, because they keep adding optimizations and functionality.  You could deal with this in a number of ways.  You could write less GWT.  You could buy a faster computer.

More realistically, you could live in your IDE, and run in development (nee hosted) mode.  However, sometimes you just have to test with javascript.  The external browser development environment can be tough to set up correctly, especially if your application depends on external resources, and you can run into weird bugs.  I’m currently dealing with an issue where I depend on an external library and it is consistently throwing an assertion exception in development but runs fine in production mode.

If I am compiling to javascript repeatedly, I often compile for just one user-agent, which saves about 80% of the compile time.  When I have code more put together, I can compile for all other browsers.  This process is not flawless, as I am currently debugging a cross browser issue (something that works fine on FF doesn’t work on Safari) but I probably wouldn’t have tested on Safari until after I was through the lion’s share of development anyway.

The way to target just one browser is to put this string in your module (.gwt.xml) file:

< set-property name="user.agent" value="safari,ie6,gecko1_8" / > (remove the spaces next to the angle brackets)

How do you find valid values?  Via this thread, I found that you look in UserAgent.gwt.xml, part of the gwt-user.jar file.  This has the javascript code that looks at navigator.userAgent.  It is not as fine grained as the ubiquitous browser detect script, but shows you what different browsers are known to GWT.

For other tips on speeding up the compile process, check out this series of posts.

[tags]gwt,user.agent,gwt compiler, slow as molasses[/tags]

3 thoughts on “Finding supported GWT user.agent values

  1. Simona says:

    Hello!

    I’m using Firefox 4.0.1 and “gecko1_8” does not work anymore. Any idea which token i can use now?

  2. moore says:

    Hi Simona,

    I don’t see a way to target FF4 as opposed to FF3. (You want to look in /com/google/gwt/user/UserAgent.gwt.xml in the gwt-user.jar file). From what I see, the existing ‘gecko1_8’ should match FF4.

    If you have a specific test case showing this, you should file an issue: http://code.google.com/p/google-web-toolkit/issues/

  3. etrusco says:

    Firefox 4.0.1 works fine for me using “gecko1_8”, what problem exactly do you see?

Comments are closed.