W3C home > Mailing lists > Public > public-html@w3.org > July 2009

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 22 Jul 2009 22:45:51 -0400
Message-ID: <4A67CEDF.4000506@mit.edu>
To: Travis Leithead <travil@microsoft.com>
CC: "public-html@w3.org" <public-html@w3.org>
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....

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

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:51 UTC