[whatwg] DOMContentLoaded and stylesheets

On 2/11/10 9:07 AM, Mathias Sch?fer wrote:
> But if there?s a script after the stylesheet, DOMContentLoaded always
> fires after the stylesheet has been loaded. The explanation I?ve found
> is that the parser waits for the stylesheet to load before subsequent
> scripts are executed.

Correct.

>> step 8 the cases that talk about "a style sheet blocking scripts"
>> specify this.
>
> Thanks for the hint. AFAICS only the third case talks about ?a style
> sheet blocking scripts?. But this case only deals with ?parser-inserted?
> inline scripts.

Ah, indeed.  For non-inline scripts the relevant part is step 2 under 
the "If the load was successful" part in 
http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#executing-a-script-block

> The question is: Is a normal external script ?parser-inserted? or not?

Yes.

> I assume the flag to be false, since that?s the default value and I
> found ?parser-inserted? to be true for XML parsing only
> (#parsing-xhtml-documents). Correct?

No.  The HTML parser state machine sets that flag in various cases.  For 
example, 
http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-inhead 
under 'A start tag whose tag name is "script"'.

> <link rel="stylesheet" href="...">
> <script src="..."></script>
>
> ... and I would like to step through the parsing algorithm. This is my
> understanding so far:
>
...
> 4. We?ve reached step 8 which you?ve mentioned above. I assume the
> fourth case is true (?If the element has a src attribute?), since the
> script is not ?parser-inserted?.

The script is in fact parser-inserted, but you still land in the fourth 
case, I think.

> 9. ?Pause until either any applicable style sheets have been fetched and
> applied, or the user agent has timed out and decided to not wait for
> those style sheets.? (step 2)
>
> -->  I guess *this* is where the waiting happens, right?

Yep.

> That means, inline script execution should also wait for stylesheets to
> load. Am I right in this reading?

Yes.

-Boris

Received on Thursday, 11 February 2010 13:00:42 UTC