Jonas Köritz Jonas Köritz - 7 months ago 37
Javascript Question

Do AMP-HTML pages have to load the JavaScript library from ampproject.org?

The documentation states that AMP HTML documents MUST


  • Contain a
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    tag as the last element in their head (this includes and loads the AMP JS library).



Does this actually mean that i can't serve an internal copy of this file (e.g. for use in a restricted network environment without internet access)?

Answer

To be a valid AMP document, you must use the <script async src="https://cdn.ampproject.org/v0.js"></script> tag.

However, in a valid AMP document, you also can specify a canonical URL. Normally, the canonical URL is an HTML document that uses services that are not allowed by the AMP architecture (e.g. customized JavaScript such as Bootstrap JS for menus). You also could assign the AMP document to the canonical tag, and then serve it to folks who do not have unrestricted access to the internet (and hence the Google CDN).