question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Require a matching amp-* tag when including new amp extension javascript

See original GitHub issue

Currently, 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:closed
  • Created 7 years ago
  • Comments:23 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
dvoytenkocommented, Apr 27, 2017

My thoughts on this:

  1. The 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.
  2. I don’t see how we can require the unused scripts to be cleaned up in most of cases at this time. The tools that are typically used today are simply unable to do this. So I’m very hesitant to force this as an error. I’m very happy with a warning however. I also have concerns that we may start forcing some workarounds to such rules that would make the situation a lot worse.
0reactions
Gregablecommented, Nov 9, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation error 'amp-iframe extension .js script' #315 - GitHub
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://3p.ampproject.net') does not match the recipient window's ...
Read more >
AMP validation errors
Tag required by another tag is missing​​ Extended components must be explicitly included in the AMP document as custom elements. To fix these...
Read more >
Google AMP - Quick Guide - Tutorialspoint
So far we have seen the mandatory tags required in the amp page. Now we will discuss the HTML elements which are allowed/not...
Read more >
AMP package - Currently in Development
User Stories As a Frontity user I want to be able to use AMP in ... The tag 'form' requires including the 'amp-form'...
Read more >
Disabling calls (view & link) on selected pages for all tags ...
The Lookup Table Extension needs to be set to run "Before Load Rules" and will create a new key value pair in utag.data....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found