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

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.

Which ones?  I know Webkit does.  Gecko used to, but that behavior was 
changed in Gecko 1.9.0 (so in Firefox 3.0.0 and later DOMContentLoaded 
does not wait for CSS resources).

Note that it never purposefully waited for CSS resources; it's just that 
in Gecko 1.8.1 and earlier the parser was paused while loading a 
stylesheet.  This is also what Webkit does.

> I believe that JQuery may depend on this behavior—but I’m not sure why.

jquery per se does not.  It does allow pages to run script easily off of 
either onload or DOMContentLoaded; pages that run script off the former 
that assumes the stylesheets are loaded might malfunction.

I believe that https://bugzilla.mozilla.org/show_bug.cgi?id=481534 is 
the only bug report we've had as a result (this is in the now more than 
two years since this change landed on trunk).

> Is the currently speced behavior “by design?” If so, please explain why..

I think the specced behavior is on purpose in terms of "fire when 
parsing completes".  The problem is that "parsing completes" happens in 
very different ways in different browsers....

-Boris

Received on Thursday, 23 July 2009 02:46:44 UTC