[whatwg] DOMContentLoaded and stylesheets

Boris Zbarsky bzbarsky at MIT.EDU
Wed Feb 10 16:16:23 PST 2010


On 2/10/10 6:55 PM, Mathias Schäfer wrote:
> In a JavaScript tutorial, I wanted to explain what DOMContentLoaded
> actually does.

It fires once the parser has consumed the entire input stream, such that 
you can rely on all the parser-created DOM nodes being present.  This is 
true in all implementations of DOMContentLoaded.  What is not consistent 
is the ordering of this event with the loading of various subresources.

> 1. Am I right that HTML5 will standardize Opera's pure DOMContentLoaded
> model, never waiting for stylesheets? My assumption is that this will
> break compatibility with the current Gecko and Webkit implementations.

Gecko currently does not wait on stylesheet loads to complete before 
firing DOMContentLoaded.  They might complete before the parser is done, 
or they might not.

> 2. Does the HTML5 parser specify that external stylesheets defer
> external script execution? As far as I understand the specs, it doesn't.

http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#running-a-script 
step 8 the cases that talk about "a style sheet blocking scripts" 
specify this.

I really wish those steps had individual IDs, and so did the cases 
inside them.  It'd make it a lot easier to link to them!

> In Gecko and IE, the loading of stylesheets also defers the execution of
> subsequent *inline* scripts. I haven't found a rule for that in the
> HTML5 parsing algorithm either.

See above.

-Boris


More information about the whatwg mailing list