Skip to content

Add crossorigin=anonymous to nomodule scripts the same as module ones#1194

Merged
sebastianbenz merged 1 commit intoampproject:mainfrom
westonruter:add/nomodule-script-crossorigin-anonymous
Apr 9, 2021
Merged

Add crossorigin=anonymous to nomodule scripts the same as module ones#1194
sebastianbenz merged 1 commit intoampproject:mainfrom
westonruter:add/nomodule-script-crossorigin-anonymous

Conversation

@westonruter
Copy link
Copy Markdown
Member

When reviewing the output of the RewriteAmpUrls transformer, I noticed that the nomodule scripts lacked the crossorigin=anonymous attribute like the the module scripts did. This makes them consistent.

Aside: It seems to be that there should also be a transformer config option for whether crossorigin=anonymous should be added in the first place. Sure it should be added by default, but for some use cases it is not good to add, namely when you are wanting to opt-in to beta/experimental channels via cookie (cf. ampproject/amp-wp#4600). Nevertheless, for this to be feasible the validator would need to make crossorigin=anonymous non-mandatory for the modulepreload link and all module scripts. I assume the cookie-based opt-in works for modules.

Copy link
Copy Markdown
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

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

Thanks!

@sebastianbenz
Copy link
Copy Markdown
Collaborator

I replicated the behaviour of the AMP cache here. Not sure what the original intention was to omit it for nomodule.

@sebastianbenz sebastianbenz merged commit 1fc78d5 into ampproject:main Apr 9, 2021
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.

3 participants