Skip to content

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

Merged
merged 5 commits into from
Aug 13, 2025
Merged

Conversation

eeeps
Copy link
Contributor

@eeeps eeeps commented Jun 5, 2025

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 scripts with blocking="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

Fixes mdn#39663

Also make clear that we are not only blocking on fetching; also on parsing/application.
@eeeps eeeps requested review from a team as code owners June 5, 2025 18:38
@eeeps eeeps requested review from dipikabh and sideshowbarker and removed request for a team June 5, 2025 18:38
@github-actions github-actions bot added Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Jun 5, 2025

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.
Copy link
Contributor

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.

@dipikabh
Copy link
Contributor

Hi @eeeps, thanks for these updates!
I've suggested a rephrasing that I hope helps to address Noam's comment. Please ping if you need any help with getting this PR over the finish line.

@sideshowbarker sideshowbarker removed their request for review June 19, 2025 01:48
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Jun 23, 2025
@bsmth bsmth added the awaiting response Awaiting for author to address review/feedback label Jul 17, 2025
@Josh-Cena
Copy link
Member

Josh-Cena commented Jul 27, 2025

@dipikabh Given it has been a month, perhaps we can move forward by applying any changes ourselves.

(Also pinging @eeeps once more for attention)

@github-actions github-actions bot added size/s [PR only] 6-50 LoC changed and removed size/m [PR only] 51-500 LoC changed labels Aug 4, 2025
@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Aug 4, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me, we can iterate again if further updates are needed.
Thanks everyone for your contribution 🙏

@dipikabh dipikabh merged commit 0e2ec54 into mdn:main Aug 13, 2025
8 checks passed
@eeeps
Copy link
Contributor Author

eeeps commented Aug 15, 2025

@Josh-Cena @dipikabh Thank you so much for picking this up where I left off, and apologies for the long silence. I kept thinking I would have time to get back to this "next week".

Reading through the committed changes I think they're technically correct (although @noamr is a better judge of that) but could use a little more explanation so folks understand how the various pieces here fit together.

Perhaps I'll have time to put another PR together soon. Thanks again!

@eeeps eeeps deleted the blocking-render-head branch August 15, 2025 04:35
@dipikabh
Copy link
Contributor

Sounds good, please feel free to send a PR to add improvements/more details 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Awaiting for author to address review/feedback Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elements with blocking=render have to be in the <head>
5 participants