ampproject / amp-toolbox

A collection of AMP tools making it easier to publish and host AMP pages.
Apache License 2.0
449 stars 243 forks source link

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

Closed westonruter closed 3 years ago

westonruter commented 3 years ago

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. https://github.com/ampproject/amp-wp/issues/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.

sebastianbenz commented 3 years ago

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