Re: Is the timing of DOMContentLoaded undefined with respect toexternal scripts?

Boris Zbarsky <[email protected]> Thu, 22 Sep 2011 14:59:26 -0400
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
On 9/22/11 2:33 PM, [email protected] wrote:
> [14:28:01.586] DOMContentLoaded:[object HTMLDocument] @ defer.htm:3
> [14:28:01.641] GET script.js [HTTP/1.1 200 OK 0ms]

This is quite weird.  How could the GET for that script happen _after_ 
DOMContentLoaded?

> Where?  It doesn't make sense in light of what you've said:
>
> "Some external scripts block the parser because the might issue
> document.write calls."
>
> but a deferred script can't write to the doc:

There's a separate clause about deferred scripts.  See 
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end 
step 3, which comes before step 4.

> so if a deferred script executes after the document has been parsed and
> can't write to the doc, why should it block the parser?

It doesn't.  It explicitly blocks DOMContentLoaded, per spec above.

-Boris