Skip to content

Integrate support for AMP release channels  #4600

@westonruter

Description

@westonruter

Feature description

Follow-up on #4390.

AMP has a new LTS channel in addition to Beta and Experimental channels. The LTS channel gets a dedicated URL while the Beta and Experimental channels are per user opt-in via cookie. Cookie-based opt-in however conflicts with the needs of serving AMP pages via service worker since it means those scripts must be cached by the service worker as opaque, meaning that they could consume much more of a site's storage budget than than they would if they had been served with crossorigin=anonymous. See ampproject/amphtml#24731 and ampproject/amphtml#27267.

The AMP plugin therefore should transition to adding crossorigin=anonymous to all scripts (and styles) that it adds to the page. This has an additional benefit of providing more guarantees for user privacy. (Ultimately this won't be necessary once self-hosting of AMP scripts is available per #4530).

Update: With the landing of ESM scripts, crossorigin=anonymous is now added to all scripts by the AMP Optimizer.

Once this is done, we then will also need an alternative to using cookies for sites to opt-in to non-stable release channel(s). In addition to LTS, there is now a way to reference the experimental and beta channels via a new optin query param: ampproject/amphtml#27587. These scripts will not be valid AMP, so when a non-stable release channel is chosen then the document must be put into dev mode.

The way to opt-in to a release channel can be accomplished via a filter like amp_release_channel which would take one string argument that can be modified by callbacks to be one of:

  • 'stable' (default)
  • 'lts'
  • 'beta'
  • 'experimental'

A special value of false should also be considered to revert to the current behavior where stable releases are used with no crossorigin=anonymous being added, which will allow for cookies to be used to control the AMP version.

Note that the Optimizer also needs to add support for LTS channel. See #4589 and ampproject/amp-toolbox#691.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

  1. Add new amp_release_channel filter.
  2. Adjust generation of script URLs based on filtered value.
  3. Adjust recognition of scripts to account for different values.
  4. Add crossorigin=anonymous to all scripts.
  5. Add dev mode to scripts when the beta or experimental channels are being used.
  6. Add support for LTS releases in the RuntimeCSS Transformer. See Add support for LTS releases in the RuntimeCSS Transformer #4589.

QA testing instructions

Demo

Changelog entry

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions