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

Render-blocking scripts should also work for inline scripts #10034

Closed
noamr opened this issue Jan 3, 2024 · 3 comments · Fixed by #10035
Closed

Render-blocking scripts should also work for inline scripts #10034

noamr opened this issue Jan 3, 2024 · 3 comments · Fixed by #10035
Labels
addition/proposal New features or enhancements

Comments

@noamr
Copy link
Contributor

noamr commented Jan 3, 2024

What is the issue with the HTML Standard?

Currently, script can block rendering only if they have a src attribute: see https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:block-rendering.

This creates an artificial constraints, where you have to make scripts external in order to make them render-blocking.
For example, the following doesn't work:

<script blocking="render" async>
  requestAnimationFrame(() => { doSomethingOnFirstFrame() });
</script>
<!-- or -->
<script blocking="render" type="module">
  requestAnimationFrame(() => { doSomethingOnFirstFrame() });
</script>

To make it work properly, the developer has to either put it in an external JS file or use parser-blocking classic scripts, which is an inferior workaround.

This becomes especially cumbersome when dealing with the pagereveal event, as registering to that event has to be done in a render-blocking script.

The proposal is to remove that limitation and allow any inline script to be render-blocking.

@zcorpan zcorpan added the addition/proposal New features or enhancements label Jan 3, 2024
@zcorpan
Copy link
Member

zcorpan commented Jan 3, 2024

This seems reasonable to me.

noamr added a commit to noamr/html that referenced this issue Jan 3, 2024
@noamr
Copy link
Contributor Author

noamr commented Jan 3, 2024

This seems reasonable to me.

Thanks @zcorpan! Doe mozilla/standards-positions#608 cover this or should I file a new standards position isssue?

@zcorpan
Copy link
Member

zcorpan commented Jan 8, 2024

@noamr the same s-p issue seems fine. Can you comment there and link to this issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements
Development

Successfully merging a pull request may close this issue.

2 participants