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

On Jul 22, 2009, at 6:45 PM, Travis Leithead wrote:

> I hope someone can clarify this question: What’s the “desired”  
> behavior of DOMContentLoaded with regard to CSS resources and why?
>
> At least two implementations wait to fire DOMContentLoaded until  
> after the CSS resources have loaded. I believe that JQuery may  
> depend on this behavior—but I’m not sure why. However, if I read  
> HTML5 correctly, this event fires immediately after parsing and  
> pending script content has finished, but does not appear to wait for  
> CSS resources. Opera fires the event in this way--as it appears to  
> be speced, but the spec’d behavior does not appear to be  
> “interoperable” universally.
>
> Is the currently speced behavior “by design?” If so, please explain  
> why..
>
> Else, perhaps it could be spec’d to match the Firefox/Webkit approach?

 From the implementation, it looks like WebKit dispatches  
DOMContentLoaded when the document is finished parsing, and does not  
explicitly wait for stylesheets. However, if we encounter a <script>  
element while a stylesheet load is pending, we block parsing until the  
stylesheet is loaded. We used to not do that, but it turned out to be  
necessary for Web compatibility. I think Gecko may always block  
parsing on stylesheet loads, or at least does so in the same cases as  
we do.

Regards,
Maciej

Received on Thursday, 23 July 2009 02:41:12 UTC