-
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
Behavior of blocking
attribute on a preload
link
#7896
Comments
For font, I don't fully understand this. What's the different between "the response arrives" and "the font is loaded"? For style / script, this is not true if it's in the document head, because the document is always render-blocked before body is inserted (and can be blocked for longer after that). And if it's in the document body, then it's pretty much the same as having an inline style / script in the document body -- a flash/shift/... should be expected. I agree that it may seem a bit redundant to use it on style/script resources. But I don't see a reason why we should ban them. Render-blocking preloads are mostly motivated by resources that are by default non-render-blocking. I've also proposed adding render-blocking a
This won't happen. For preloads, rendering is unblocked when the resource is loaded, not when it's used. |
The time where the response is processed and turned into an actual font can happen after the response arrived, not necessarily synchronously.
OK, but in this case, how did render-blocking the preload helped? It had no effect... if the script is anyway render-blocking it remains render-blocking and vice versa. The only thing the blocking-preload would do is shift the FOUC around to a different point in time, potentially shorter.
I'll read and comment on that one, thanks for the pointer.
Right, hence there would be a potential FOUC gap. If the resource is used late - and you unblock on response - The logic here is that rendering is not a direct result of the loading chain, but rather an effect that may happen later, potentially asynchronously. So tying something render-related to the fetching process is racy. |
Thanks for finding out this issue. I've discussed this issue within the Chrome team, and we agreed that render-blocking preload is a problematic idea. We've decided to:
Question: How about |
I think those are good moves! Thank you.
I think it has the same issues as |
Is there any procedure needed to remove cc @domenic |
Mainly upload an HTML PR and make sure the WPTs are up to date. |
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447}
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447}
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447}
…` from preload and modulepreload links, a=testonly Automatic update from web-platform-tests [renderblocking] Remove `blocking=render` from preload and modulepreload links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447} -- wpt-commits: 5f3c4872a168e983f9310845ce739ef8e356584f wpt-pr: 34083
…` from preload and modulepreload links, a=testonly Automatic update from web-platform-tests [renderblocking] Remove `blocking=render` from preload and modulepreload links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447} -- wpt-commits: 5f3c4872a168e983f9310845ce739ef8e356584f wpt-pr: 34083
…oad links ... following the discussion in whatwg/html#7896 Bug: 1271296 Change-Id: I2ac45f4697810350170d217a7b8d16880e6b89a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648301 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1005447} NOKEYCHECK=True GitOrigin-RevId: 1372f2379a46b86177b5537b5be77a00c83c6bda
Hi, I would like to re-open this, as I think render blocking on preload can be useful. When using declarative shadow DOM, loading a stylesheet currently have two different behaviors:
I'm waiting to check Firefox implementation. I have raised this issue here: #9232 and it seems that Chrome might be the incorrect implementation. I would prefer for stylesheet to be blocking, as otherwise the following will cause FOUC, which in my opinion defeat the purpose of declarative shadow DOM:
If the spec is clarified and Safari behavior is adopted, this means we need to have a way to block the rendering in this context, so we would need to have this and this to be blocking:
In this context we cannot remove the preload as otherwise the styles would leak into the main document and no longer be scoped to the Shadow DOM (while the preload allows to ensure it is just downloaded but not executed). Honestly, I would prefer the declarative shadow dom spec to be clarified and be blocking, but I wanted to raise this use case as I feel it is an important one. |
According to the spec, a
<link rel=preload blocking=render />
would block rendering until the resource is fetched.This behavior seems a bit off, or in other words I have doubts about it.
If taken as specified, this could lead to a FOUC - as the time between the response arrives and the font is loaded / style is parsed / script is executed is not render-blocked.
It can create strange situations, e.g. with
<link rel=preload render=blocking as=script />
and a corresponding<script>
without a blocking keyword. Should it or should it not block? Should it block while fetching the preload but not while executing the script? If it blocks until the script is executed, what if it's not executed at all?OTOH, when evaluating scripts/styles, their subresources (imported scripts/styles) are already implicitly render-blocking. So re-defining them as render-blocking in the preload is redundant.
I suggest that preloads should not be render-blocking at all, and instead to allow render-blocking on particular type of resources that cannot currently do that, like fonts. Maybe:
This would also make the render-blocking part of the style's content, rather than an external side-effect of one of its headers, which would require web developers to juggle between CSS authoring and backend configuration of HTTP headers.
If we want this to affect the fetch priority, it could be something like:
Specify the blocking for the preload as a priority, but not block the rendering indefinitely if the resource is loaded but not used.
WDYT? @xiaochengh @yoavweiss
The text was updated successfully, but these errors were encountered: