Discussion: Require a matching amp-* tag when including new amp extension javascript
See original GitHub issueCurrently, if an AMP page makes use of an amp extension (eg <amp-foo>
) the AMP validator requires that the matching script tag be located on the page, for example:
<script async custom-element='amp-foo' src='https://cdn.ampproject.org/v0/amp-foo-0.1.js'></script>
However, the reverse is not true. You can include amp-foo-0.1.js
without the presence of any <amp-foo>
tag and it is not a validation error.
This results in an anti-pattern of folks generating a header for a site that includes the superset of all javascript extensions that they may want to use, even if a given page does not use that extension. The AMP cache can strip unused extensions, but the origin is still affected.
See Design Principles: “User Experience > Developer Experience > Ease of Implementation.”
When in doubt, do what’s best for the end user experience, even if it means that it’s harder for the page creator to build or for the library developer to implement.
I’d like to propose that for new extensions, we enforce both requirements. If amp-new-extension-0.1.js
is on the page but <amp-new-extension>
isn’t, for example, that would be a validator error. Existing extensions would be grandfathered in, at least for now.
The big risk I see is that a developer using the superset header might add one of these new extensions to their header and accidentally invalidate their entire site without realizing it.
Issue Analytics
- State:
- Created 7 years ago
- Comments:23 (19 by maintainers)
My thoughts on this:
amp-live-list
case where the new update can require new extensions should be supported directly and I would consider it a bug: the new updates should automatically install newly required extensions. This is typically also a rather easy fix. Please file an issue if this is the case.As per no response, closing.
Of note, I think we’re also going to remove the warnings for the grandfathered unused extensions, but leave the errors for all new unused extensions.