Re: Placement of boot script in body vs. head

2012-11-09 Thread Michael Allan
Hi Thomas,

 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.

Okay, so body placement is required in this case.  OTOH if we don't
write to the document before the boot script, then I guess there's no
reason to avoid placing it in the head if that works (as it seems to),
despite what the guide recommends.

Michael


Thomas Broyer said:
 
 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.
  
 
   Now that HTML has the async script 
   attribute
  http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-async,
   
 
   that would be another option if you want to keep your script tags in 
   the header.  (Note that there's a semantics difference since scripts 
   might execute out of order depending on caching and network speeds.) 
 
 
 Also, it might only work with the xsiframe linker, as the others use 
 document.write() which IIRC could destroy the document when run async.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Placement of boot script in body vs. head

2012-11-08 Thread Thomas Broyer


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.
 

  Now that HTML has the async script 
  attribute
 http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-async,
  

  that would be another option if you want to keep your script tags in 
  the header.  (Note that there's a semantics difference since scripts 
  might execute out of order depending on caching and network speeds.) 


Also, it might only work with the xsiframe linker, as the others use 
document.write() which IIRC could destroy the document when run async.
 

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Im8rwFrNk08J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Placement of boot script in body vs. head

2012-11-07 Thread Matthew Dempsky
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.

Now that HTML has the async script
attributehttp://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-async,
that would be another option if you want to keep your script tags in the
header.  (Note that there's a semantics difference since scripts might
execute out of order depending on caching and network speeds.)


On Wed, Nov 7, 2012 at 5:00 PM, Michael Allan m...@zelea.com wrote:

 Why place the boot script in the document body, instead of the head?

 https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideHostPage

 https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideBootstrap

 I've ignored the instructions and placed it in the head (std, xs and
 xsiframe linkers) with no apparent problems.  What am I missing?

 --
 Michael Allan

 Toronto, +1 416-699-9528
 http://zelea.com/

 --
 You received this message because you are subscribed to the Google Groups
 Google Web Toolkit group.
 To post to this group, send email to google-web-toolkit@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Placement of boot script in body vs. head

2012-11-07 Thread Michael Allan
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

So best is top of body.  But why not even earlier in the head?

Michael


 Now that HTML has the async script
 attributehttp://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#attr-script-async,
 that would be another option if you want to keep your script tags in
 the header.  (Note that there's a semantics difference since scripts
 might execute out of order depending on caching and network speeds.)

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.