Somehow make Link rel=stylesheet's [fetch and process the linked resource] algorithm do the following:
- If el [contributes a script-blocking style sheet], increment el's [node document]'s [script-blocking style sheet counter by one.
(^Either by passing some custom steps to [default fetch and process the linked resource], or overriding the algorithm)
The [process the linked resource] algorithm for this type of resource is as follows, given el, success, and response:
- ...
- Queue a task to:
- Fire events accordingly
- [Create] a [CSS style sheet] whose properties
- If el [contributes a script-blocking style sheet]:
- Assert: el's [node document]'s script-blocking style sheet counter is greater than 0.
- Decrement el's [node document]'s script-blocking style sheet counter by one.
The [update a style block algorithm is as follows]:
- Let element be the [style] element.
- ...
- If element [contributes a script-blocking style sheet], increment element's [node document]'s [script-blocking style sheet counter] by one.
- [Create] a [CSS style sheet] with the following properties...
Once the attempts to obtain the style sheet's critical subresources are complete, of if the style sheet had no critical subresources:
- Fire events accordingly.
- If element [contributes a script-blocking style sheet]:
- Assert element's [node document]'s [script-blocking style sheet counter] is greater than 0.
- Decrement element's [node document]'s [script-blocking style sheet counter] by one.
An element el in the context of a [Document] of an [HTML parser] or [XML parser] [contributes a script-blocking style sheet] if the following are true:
- el was created by that Document's parser.
- el is either a [style] element, or a [link] element that was an [external resource link that contributes to the styling processing model] when the element was created by the parser.
- If el is a [link] element, it's [media] attribute's value [matches the environment].
- el's style sheet was enabled when the element was created by the parser. [not so sure about this, since link elements don't create style sheets until the resource is loaded]
- The last time the [event loop] reached [step 1], the element's [root] was that [Document].
- The user agent hasn't given up on that particular style sheet yet. A user agent may give up on a style sheet at any time.
A [Document] has a script-blocking style sheet counter, which is a number, initially 0.
A [Document] has a style sheet that is blocking scripts if its script-blocking style sheet counter is greater than 0.
A [Document] ...