On Tue, 02 Feb 2016 02:27:20 +1100, Patrick Meenan <
pme...@chromium.org>
wrote:
> *Contact email*:
>
pme...@chromium.org
>
> *Spec*
> N/A. The internal parser behavior is not spec'd.
The current behavior is actually specified in HTML.
https://html.spec.whatwg.org/multipage/semantics.html#a-style-sheet-that-is-blocking-scripts
> *Summary*
I think this is a radical proposal and it would be interesting to evaluate
the pros and cons and compare with other approaches. Simplifying the
architecture seems like a clear pro.
As for cons, I can think of:
* Doing this would be a step back in terms of interop, I believe. The
logic to keep track of pending stylesheets and block inline scripts when
there are pending stylesheets is specified in the HTML spec and is, I
think, implemented in all engines (probably not perfect interop, but
still).
* Blocking parsing could regress performance in various cases, for
instance if a page has first an async script, then an external stylesheet,
and then a <video preload>; the video would not start to load until the
stylesheet is loaded. It would be possible to add <video> knowledge to the
speculative scanner, but that adds complexity to the speculative scanner
(and hence new bugs), and I assume <video> is not the only thing that
could regress.
* Blocking parsing might not be Web compatible. Given setTimeout(),
mutation observers, etc, it is possible to tell the difference between
blocking parsing and not blocking parsing. In particular there can be
pages that do setTimeout() and make assumptions about what is available in
the "future" DOM when it runs.
> *Is this feature supported on all six Blink platforms (Windows, Mac,
> Linux,
> Chrome OS, Android, and Android WebView)?*
> Yes
>
> *Demo link*
>
http://test.patrickmeenan.com/css/image.html
>
> *Interoperability and Compatibility Risk*
> Browser behavior in this area is quite varied. The change will bring
> Chrome in line with how IE and Edge behave.
>
> *Chrome (currently)*: Blocks drawing of all content before and after the
> external css as soon as it is parsed
> *Safari*: Same as Chrome (behavior inherited from WebKit)
> *Firefox*: External stylesheets in the body do not block drawing of any
> content, including content referenced after the stylesheet (treated
> completely async)
> *Edge*: Content before external stylesheets is drawn independently of the
> sheet loading and content referenced after it is blocked until after the
> sheet is loaded (same as proposed behavior)
> *IE 11*: Same as Edge
I haven't tested Edge right now, but I very much doubt that it actually
blocks parsing for external stylesheets. I had assumed that it only blocks
layout of the post-external-stylesheet part of the DOM until the
stylesheet is loaded.
What I would suggest is to investigate more closely what Edge does here,
and consider blocking layout instead of blocking parsing, before going
ahead with implementation of blocking parsing. Also I would suggest that
if we do decide that blocking parsing is the better solution, that we have
other vendors on board with doing the same so that we don't end up with
worse interop, and so that we can change the HTML spec to match.
> The biggest risk is the potential for reduced performance by not
> continuing
> to parse the DOM while the stylesheet loads asynchronously. Before the
> preload scanner this would have been a much more significant issue as
> external resources would not be discovered but that is no longer the
> case.
> The parser would block as soon as it hit the next script tag anyway so
> the
> only loss is for the time to actually build the DOM nodes between the
> link
> tag and when the parser would have been blocked anyway.
>
> *OWP launch tracking bug*
> *Entry on the feature dashboard*
> No entry created (though happy to create one if it is deemed necessary).
>
--
Simon Pieters
Opera Software