[whatwg] defer on style, depends

Ian Hickson ian at hixie.ch
Fri Feb 13 11:16:44 PST 2009


On Fri, 13 Feb 2009, Boris Zbarsky wrote:
> 
> The current Gecko behavior is that any stylesheet load started by parsing a
> <style> or <link> tag will increment a counter on the document (well, on a
> per-document script loader object, to be more precise). Completion of the load
> will decrement the counter.  While the counter is nonzero, <script> execution
> is blocked.  When it goes back to 0, the first pending script (if any) is run.
> If this increments the counter again, no more scripts are run until the count
> goes to 0 again.
> 
> So it doesn't matter how the script is created/inserted, but the only
> stylesheets that block scripts are ones that the parser knows about.  So only
> the ones present in the original source or added via document.write.  If you
> createElement a <link> and insert it into the DOM, it won't block script
> execution.  Also, <link> elements pointing to alternate style sheets don't
> block script execution.

So in this:

   <!DOCTYPE html>
   ...
   <script>
    document.write('<link rel=stylesheet href=style>');
    document.write('<script>a();<\/script>');
    b();
   </script>

...is the script paused after the second document.write() call, before a() 
and b() execute?

(When replying please leave your text above in the reply, so that I don't 
lose context -- thanks!)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list