My favorites | Sign in
Google
                
Search
for
Updated Aug 28, 2008 by galgwt.reviews
FAQ_WhenDoModulesLoad  
When do my modules load during the bootstrap sequence?

The Bootstrap Sequence

Consider the following HTML page that loads a GWT module:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body onload='alert("w00t!")'>
    <img src='bigImageZero.jpg'></img>
    <script source='externalScriptZero.js'></script>
    <img src='bigImageOne.jpg'></img>
    <img src='reallyBigImageTwo.jpg'></img>
    <script src='com.example.app.App.nocache.js'></script>
    <script src='externalScriptOne.js'></script>
  </body>
</html>

The following principles are needed to understand the sequence of operations that will occur in this page:

Applying these principles to the above example, we obtain the following sequence:

  1. The HTML document is fetched and parsing begins.
  2. Begin fetching bigImageZero.jpg.
  3. Begin fetching externalScriptZero.js.
  4. bigImageZero.jpg completes (let's assume). Parsing is blocked until externalScriptZero.js is done fetching and evaluating.
  5. externalScriptZero.js completes.
  6. Begin fetching bigImageOne.jpg and reallyBigImageTwo.jpg simultaneously.
  7. bigImageOne.jpg completes (let's assume again). com.example.app.App.nocache.js begins fetching and evaluating.
  8. ...nocache.js completes, and the compiled script (...cache.js) begins fetching (this is non-blocking).
  9. ...cache.js completes. onModuleLoad() is not called yet, as we're still waiting on externalScriptOne.js to complete before the document is considered 'ready'.
  10. externalScriptOne.js completes. The document is ready, so onModuleLoad() fires.
  11. reallyBigImageTwo.jpg completes.
  12. body.onload() fires, in this case showing an alert() box.

This is a bit complex, but the point is to show exactly when various resources are fetched, and when onModuleLoad() will be called. The most important things to remember are that

A Note on Multiple GWT Modules and EntryPoints

If you have multiple EntryPoints (the interface that defines onModuleLoad()) within a module, they will all be called in sequence as soon as that module (and the outer document) is ready.

If you are loading multiple GWT modules within the same page, each module's EntryPoints will be called as soon as both that module and the outer document is ready. Two modules' EntryPoints are not guaranteed to be fired at the same time.


Sign in to add a comment