Re: [HTML5] DOMContentLoaded fires before CSS resources loaded?

On Sun, 4 Oct 2009, Boris Zbarsky wrote:
> Ian Hickson wrote:
> > For _any_ <script> element, internal or external, parser-inserted and
> > dynamically inserted, once the script has loaded and is about to be
> > executed, if there are "pending style sheets" (defined below), then act as
> > if the script had not yet finished loading, until such time as any "pending
> > style sheets" have loaded.
> > 
> > "Pending style sheets" are those that were referenced by <link> or <style>
> > elements inserted by the parser, or Link: HTTP headers, and that were
> > inserted into the document (by the parser) _before_ the relevant <script>
> > was inserted into the document (by the parser or script).
> Assuming "have loaded" includes loading all @import descendants, I believe
> this would more or less match Gecko's current behavior, yes, with two
> differences I can think of:
> 1) Stylesheets are only considered pending if they were in the then-selected
> stylesheet set when they were inserted into the document.  That is, alternate
> stylesheets don't block anything from happening in Gecko right now.
> 2) Gecko does not impose the "before the relevant <script>" condition. If a
> stylesheet is pending and you insert a <script> dynamically (off a timeout
> say), and then another stylesheet load starts from the parsr (which didn't
> block on the dynamically inserted script, of course) before the previous one
> completes, the <script>s execution will wait on the end of that second
> stylesheet load as well.
> I'm not 100% wedded to this behavior, though I do happen to think it 
> makes sense (modulo caveat 2 above possibly).  But I'm biased, 
> obviously; if I thought it didn't make sense I would have implemented it 
> differently.  If there are obvious issues with it, or just obvious 
> improvements to be made, I'd be quite happy to know what they are.  I 
> can see how the "inserted before the relevant <script>" condition might 
> make more sense, but it involves a lot more bookkeeping (in particular 
> keeping track of which stylesheets are loading, not just whether any are 
> loading at all), which is sort of why we didn't implement it that way 
> (or rather why the idea hadn't even been considered).


> > It also sounds like you want the parser to stop blocking everything 
> > while waiting for an external script to finish loading.
> Right; on this I feel much more strongly than on the precise behavior of 
> stylesheet/script interaction...  Blocking processing of data in the 
> parser is a must.  I'm not sure blocking processing of everything else 
> is reasonable.

Also done.

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

Received on Sunday, 11 October 2009 07:52:39 UTC