On Thursday, November 8, 2012 3:50:47 AM UTC+1, Michael Allan wrote:
Hi Matthew,
> My understanding is that when the browser sees a <script> tag, it
> needs to block until the script resource is available before it can
> resume parsing and displaying the rest of the page's contents.
> Putting the <script> tag at the end helps avoid this so the page
> renders faster.
I was thinking along the same lines at first. But then the guide
says, "You want to put the GWT selection script as early as possible
within the body, so that it begins fetching the compiled script before
other scripts (because it won't block any other script requests)."
https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideBootstrap
It really depends on your use case and the user experience you want to have during loading.
For instance, a very easy way to have a "Loading..." text on the page:
<body>
<noscript>
You must have JavaScript enabled blah blah blah
</noscript>
<script>
document.write("<div id='loading'>Loading…<" + "/div>");
</script>
<script src="myapp/myapp.nocache.js"></script>
With the first thing you do in the onModuleLoad is Document.get().getElementById('loading').removeFromParent();
The "bootstrap script" is "as early as possible within the body" yet not at the very beginning.
Also, it might only work with the xsiframe linker, as the others use document.write() which IIRC could destroy the document when run async.