0

I am trying to find out how code-splitting works in GWT. For this, I am following the example they have provided at https://developers.google.com/web-toolkit/doc/latest/DevGuideCodeSplitting. It works as expected, in the 2nd case with the RunAsyncCallback, the string Hello, AJAX is not visible in the cache.html files. But when running in development mode, when I click the button, I don't see any Ajax request being fired in Firebug even though the alert shows just fine.

So it means that the content is present somewhere around (perhaps in the cache.js files), it is not fetched from the server on the fly. If so, then what is the point of code-splitting?

SexyBeast
  • 7,913
  • 28
  • 108
  • 196
  • 1
    In dev mode, the code is compiled on the fly (http://stackoverflow.com/questions/3821765/gwt-developer-mode-code-server) – Jiri Kremser Mar 16 '13 at 21:13

1 Answers1

4

The requests are only fired in compiled mode. In development mode, the GWT browser plugin takes over, and forwards the calls to the code server.

In compiled mode, it's all there as you would expect it. Just have a look at the directory war/mymodulename/deferredjs/

Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
  • Okay, so you are saying that if I deploy the compiled code in Tomcat, I will see the request being fired? – SexyBeast Mar 16 '13 at 21:08
  • Yes, I have verified this in my own projects. – Chris Lercher Mar 16 '13 at 21:11
  • Another question, on subsequent clicks, I don't see requests firing any more. This is of course, desired, but is it guaranteed? I mean, do I need a flag check, like it being initially false, then, checking for it inside the handler, if false, run the async, and set it to true, else, it means that it has already been loaded, just run it? – SexyBeast Mar 16 '13 at 21:18
  • 1
    Don't worry, it all works without any additional checks. The reason why this works is, that each permutation gets a unique name, so it can be cached. Just make sure to send the [correct caching headers](http://stackoverflow.com/a/3001556/291741) – Chris Lercher Mar 16 '13 at 21:47
  • Fine. Another question, imagine I have a substantial chunk to fetch on the fly. The first time, it will obviously take a lot of time to fetch, so I intend to display a loading GIF image, and then, inside the `onSuccess` handler, remove that, and display the code fetched. For subsequent requests, will the GIF still show for a split second before disappearing? – SexyBeast Mar 16 '13 at 21:50
  • It will show for a split second and its okay ( we have the same behavior in our 100+ screen app) and makes the customer/user feel the app getting faster :) – appbootup Mar 17 '13 at 09:05
  • Can't I overcome it by setting a flag, which will be set to true first time..?So next time onwards, the loading display logic, which will work only if the flag is false, won't work? – SexyBeast Mar 17 '13 at 18:13