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

Link preloading should keep integrity hashes in the header #40841

Merged
merged 1 commit into from
Dec 17, 2020

Conversation

etiennebarrie
Copy link
Contributor

When a stylesheet or javascript link tag (or preload link tag) is output in the view, it also gets sent as a Link header for preloading. This Link header is missing the integrity attribute even when one is set on the tag, which prevents the browser from using the preloaded resource.

On Chrome, having an integrity hash on the stylesheet <link> tag, causes a console warning because the hash is missing from the Link header:

A preload for '<asset url>' is found, but is not used due to an integrity mismatch.

It also causes a double load of the resource, because the preloaded one without the integrity is dropped,

@rails-bot rails-bot bot added the actionview label Dec 14, 2020
When a stylesheet or javascript link tag (or preload link tag) is output
in the view, it also gets sent as a Link header for preloading. This
Link header is missing the integrity attribute even when one is set on
the tag, which prevents the browser from using the preloaded resource.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
@rafaelfranca rafaelfranca merged commit faa27dd into rails:master Dec 17, 2020
@rafaelfranca rafaelfranca deleted the link-preload-integrity branch December 17, 2020 00:58
rafaelfranca added a commit that referenced this pull request Dec 17, 2020
Link preloading should keep integrity hashes in the header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants