ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

The extension 'amp-gist' was found on this page, but is unused. - Remove warning #24532

Closed Stefany93 closed 4 years ago

Stefany93 commented 5 years ago

Describe the new feature or change to an existing feature you'd like to see

Remove the warning that the AMP validator screams if amp-gist is un-used in a page.

Describe alternatives you've considered

I am creating a Jekyll + AMP website and on my blog I am using amp-gist for code highlight. But if the user is on the, let's say homepage the page is invalidated due to the warning. Since my build is static, it will be pretty difficult to remove the component unless amp-gist is used (to be honest I have no idea how to do it)

Additional context

As I understand it, the validator will scream when a component isn't used only if said component is experimental, but amp-gist isn't.

Gregable commented 4 years ago

This has nothing to do with experimental vs. not. The validator errors on all unused extensions created since that feature was added to the validator (multiple years now). The issue is that loading the javascript for these extensions has a performance impact for the AMP page. This is an intentional validator feature.

Recommended solution is to have your static site generator inspect the page for <amp-gist> and choose to add or not add the required javascript based on the presence of the page.

Stefany93 commented 4 years ago

@Gregable thank you!