-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Clarify requirements for render-blocking #39809
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
base: main
Are you sure you want to change the base?
Conversation
Fixes mdn#39663 Also make clear that we are not only blocking on fetching; also on parsing/application.
|
||
To ensure that your initial HTML has been parsed and will always render consistently before the transition animation runs, you can use [`<link rel="expect">`](/en-US/docs/Web/HTML/Reference/Attributes/rel#expect). In this element, you include the following attributes: | ||
|
||
- `rel="expect"` to indicate that you want to use this `<link>` element to render block some HTML on the page. | ||
- `href="#element-id"` to indicate the ID of the element you want to render block. | ||
- `blocking="render"` to render block the specified HTML. | ||
|
||
> [!NOTE] | ||
> In order to block rendering, `script`, `link`, and `style` elements with `blocking="render"` must be in the `head` of the document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and present before the <body>
element is parsed.
Adding an element to the <head>
after <body>
is parsed cannot block rendering.
Hi @eeeps, thanks for these updates! |
This pull request has merge conflicts that must be resolved before it can be merged. |
Description
Clarify requirements for render-blocking. Also make clear that we are not only blocking on fetching; also on parsing/application.
Motivation
I was caught out when trying to implement render-blocking, because I did not understand from either MDN or reading the spec that
script
s withblocking="render"
needed to appear in the head. This started a series of conversations with @noamr and @zcorpan about what render-blocking needs (and what needs render-blocking) which I am trying to capture in this PR.Additional details
(see linked spec reference and Bluesky link in #39663).
I'm not sure these notes need to be in all of these places, but figured that removing them would be easier for reviewers than finding all of the places they could/should be.
Related issues and pull requests
Fixes #39663