-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature proposal: blocking="render"
attribute on <link>, <script> and <style>
#7131
Comments
Should consider how this relates to HTTP link header preloads, as well as upcoming 103 Early Hints. From personal experience FOUC is a non-issue using the HTTP header equiv. Unsure about how the implementation differs, can't find spec. ... also wondering potential fun edge cases /w stuff like |
Without expanding the scope of this, I think it may be interesting to look at an alternative spelling (e.g. |
One aspect which is worth thinking through in the context of this proposal is ensuring the browser fetches and parses enough of the Document before rendering. It's unclear to me how the browser decides when the parser should yield for first render. |
renderblocking
attribute on <link> and <script>blocking="render"
attribute on <link> and <script>
The proposal has been updated: Instead of a boolean attribute, it's now a string attribute The syntax is intentionally left open for future extensions (so we may ultimately have something like For details, please refer to the full version, which also has addressed some feedbacks that we have received so far. |
Thanks for the update. While the current proposal only allows for I suggest using "split on ASCII whitespace", same as e.g. |
Good idea! I'll update the proposal Edit: Updated. Now the syntax is a set of space-separated tokens, and the UA should ignore all unrecognized tokens. |
Looks good 👍 On this point:
Can this be expanded? |
I'll expand this part into a section. Time to go through every attribute to see how they work together :) |
Proposal updated with more details filled in:
The latest full version is at here. |
The detailed proposal is looking quite good. In terms of other render-blocking resources, I think modulepreload should get the same treatment. I wonder about prefetch and prerender, but probably those don't make sense as render-blocking. Thoughts welcome. |
Per the triage call the |
@domenic |
I'll update the proposal to include |
Can you elaborate on that last sentence? It was my impression that HTML could manage this itself through a counter on |
Right, so I think what @annevk and I were envisioning was something like this:
Then in the future we could have something where It's possible we could get away with a counter instead of a set. However, that might require some tricky bookkeeping in some cases to ensure that we never decrement twice for the same resource (e.g., decrement once for removing the |
Should probably also specify that adding this attribute after the resource has loaded won't add the element to the set. |
Thanks @domenic! I was thinking about allowing
This should be satisfied already, because we process this attribute only when we start fetching. |
blocking="render"
attribute on <link> and <script>blocking="render"
attribute on <link>, <script> and <style>
Closes whatwg#7131. The new render-blocking mechanism is used to specify cases where <script> and <link> can be render-blocking in all browsers, but were not according to the spec. This closes whatwg#3355 (although note that whatwg#696 remains open).
(Edit: The syntax is changed into
blocking="render"
for extensibility. )(Please refer to the full proposal for formal details and more discussion)
Explainer
All current browsers already have a render-blocking mechanism: after navigation, the user agent will not render any pixel to the screen before all stylesheets and synchronous scripts in
<head>
are loaded and evaluated (or a UA-defined timeout is reached)1. This prevents a Flash of Unstyled Contents (FOUC) and ensures critical scripts (like framework code) are executed, so that the page is usable after the first rendering cycle.In this proposal, we extend the above idea and propose a new attribute
blocking
that can be added to<link>
,<script>
and<style>
elements in<head>
. For now, we would only allow one valueblocking="render"
to support the most demanding use cases, but we would also like to keep the syntax open for future extensions.Use cases
requestAnimationFrame()
callbacks should not be fired2. So we can add arequestAnimationFrame()
in<head>
to perform some tasks right before the first rendering cycle to, e.g., ensure a better-looking first paint:Footnotes
[1] The exact behaviors differ slightly.
[2] Current browsers have different behaviors, and this proposal would like to standardize it. See test case.
The text was updated successfully, but these errors were encountered: