Skip to content
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

Document blocking attribute for link,script,style elements #14648

Merged
merged 6 commits into from
Nov 30, 2022

Conversation

abinpaul1
Copy link
Contributor

@abinpaul1 abinpaul1 commented Apr 4, 2022

Summary

Document the blocking attribute on script, link and style HTML elements and basic examples for how to use it.

Motivation

The attribute was added to HTML spec in whatwg/html#7474

Supporting details

Explainer for the added attribute : whatwg/html#7131

Related issues

Fix #12900

Metadata

  • Adds a new document
  • Rewrites (or significantly expands) a document
  • Fixes a typo, bug, or other error

@abinpaul1 abinpaul1 requested a review from a team as a code owner April 4, 2022 12:09
@abinpaul1 abinpaul1 requested review from dipikabh and removed request for a team April 4, 2022 12:09
@github-actions github-actions bot added the Content:HTML Hypertext Markup Language docs label Apr 4, 2022
@teoli2003
Copy link
Contributor

Thanks! I think we should wait for an implementation before merging this. Implementation can get stalled.

What about making this a draft PR meanwhile?

@abinpaul1 abinpaul1 marked this pull request as draft April 4, 2022 12:42
@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2022

Preview URLs

Flaws (1)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/HTML/Element/script
Title: <script>: The Script element
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/Element/load_event does not exist

(comment last updated: 2022-11-30 15:12:58)

@@ -34,6 +34,9 @@ This element includes the [global attributes](/en-US/docs/Web/HTML/Global_attrib
- : A cryptographic nonce (number used once) used to allow inline styles in a [style-src Content-Security-Policy](/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
- {{htmlattrdef("title")}}
- : This attribute specifies [alternative style sheet](/en-US/docs/Web/CSS/Alternative_style_sheets) sets.
- {{htmlattrdef("blocking")}}
- : This attribute explicitly indicates that certain operations should be blocked on the fetching of the script. The operations that are to be blocked must be a space-separated list of blocking attributes listed below.
Copy link
Contributor

Choose a reason for hiding this comment

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

"script" doesn't seem correct here. It would be good to clarify if renderring will be blocked on subresources loading like background-image: url(…) or @import

Copy link
Contributor Author

@abinpaul1 abinpaul1 Apr 25, 2022

Choose a reason for hiding this comment

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

I'll update it as ..certain operations should be blocked on the fetching of external resources. Would that be better?
I do believe that subresource loading inside the <style> tag does block rendering.
@xiaochengh if you could maybe clarify, I'll promptly update the doc based on the clarification. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we talking about the attribute on the <style> element here?

For <style>, as per spec, rendering will be blocked on the "critical subresources", i.e. the subresources blocking the load event of the element. Current browsers generally only consider @import-ed stylesheets as critical subresources. Fonts and background images are not critical subresources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @xiaochengh

Are we talking about the attribute on the <style> element here?

Yes

@mnoorenberghe I have updated the docs to mention the cases of background-image: url(…) and @import and fonts

@abinpaul1 abinpaul1 force-pushed the add_blocking_attr branch from d3a7cfd to f3bbb46 Compare May 5, 2022 14:43
@Josh-Cena Josh-Cena added the on hold Waiting on something else before this can be moved forward. label Sep 13, 2022
@sideshowbarker sideshowbarker marked this pull request as ready for review November 7, 2022 07:49
@sideshowbarker
Copy link
Collaborator

Per https://chromium.googlesource.com/chromium/src/+/f94b3a1c0ed4505190de7c149d6330600589a995 this seems to have shipped in Chrome 105 in August — so I’ve gone ahead and flipped it from Draft back to Review for Review.

Is there anything else we’re waiting on in order to merge this? @mnoorenberghe Should we consider #14648 (review) to be resolved?

@sideshowbarker sideshowbarker removed the on hold Waiting on something else before this can be moved forward. label Nov 7, 2022
Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

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

I think we should land this.

files/en-us/web/html/element/link/index.md Outdated Show resolved Hide resolved
files/en-us/web/html/element/style/index.md Outdated Show resolved Hide resolved
@Elchi3 Elchi3 merged commit ae3aa16 into mdn:main Nov 30, 2022
@abinpaul1 abinpaul1 deleted the add_blocking_attr branch November 30, 2022 17:22
@abinpaul1
Copy link
Contributor Author

Don't we need to also add browser compat data for this?

@Elchi3
Copy link
Member

Elchi3 commented Dec 7, 2022

Don't we need to also add browser compat data for this?

Yes, that would be good. Do you want to create a PR?

hamishwillee pushed a commit to hamishwillee/content that referenced this pull request Dec 12, 2022
* Document blocking attribute for link,script,style tag

* Appease the markdown linter

* Apply suggestions from code review

Co-authored-by: Brian Thomas Smith <[email protected]>
Co-authored-by: Michael[tm] Smith <[email protected]>
Co-authored-by: Florian Scholz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTML Hypertext Markup Language docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content suggestion: New HTML feature blocking=render on <script>, <link>, <style>
8 participants