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

Subresource link headers are implemented but not specified #8865

Open
noamr opened this issue Feb 8, 2023 · 2 comments
Open

Subresource link headers are implemented but not specified #8865

noamr opened this issue Feb 8, 2023 · 2 comments

Comments

@noamr
Copy link
Contributor

noamr commented Feb 8, 2023

This feature allows the browser to read the link headers of subresources and use them to preload other subresources.
A common use case is to preload fonts from a stylesheet.
See previous attempt to spec this: #7691

This should probably be either specified or removed from implementations.

@noamr
Copy link
Contributor Author

noamr commented Feb 8, 2023

I was involved in spec'ing it and reached a conclusion that it's a problematic feature, and that speculative preloading based on the contents of a style/script in conjunction with standard document preloads is a better alternative.

A subresource doesn't have the whole picture. For example, a style knows that it points to webfonts, but it doesn't know if the DOM is going to include text that uses these fonts in practice. Only the HTML itself knows whether it is a good/bad idea to preload the font, and preloading it based on a link header from the stylesheet can end up with preloading unused fonts.

The place where this is useful with minimal footguns is with deep nested stylesheet imports and deep nested JS modules, as the style/script can guarantee that those resources are going to be needed (and even then, they could be media-gated etc so the footgun is still there).

So I've reached a conclusion that preloads is something that only the document should be doing and it shouldn't be chained.

@yoavweiss wdyt?

@0xdevwrite
Copy link

A subresource doesn't have the whole picture...Only the HTML itself knows whether it is a good/bad idea to preload...

Agree with this point, but instead of abandoning link header preloading of subresources altogether, it might make sense to allow subresources to specify their preloads and then have the parent document send a header to opt-in to "use" the link preload headers present in the subresource.

This allows the parent document to not need to know about all the subresources that a subresource might load and instead defer that decision to the subresource itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants