7

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)?

Jonas Köritz
  • 2,606
  • 21
  • 33
  • 1
    I personally don't like google being able to track my visitors. That's also an argument to host it yourself. – ibotty Apr 21 '16 at 14:29
  • 1
    You certainly can serve a copy using your own method (e.g. a restricted, network).. But, to be a valid AMP document, it (also) must use the Google CDN managed by the above JS. Is that an answer to your question, or am I missing some other part of your question? – Jay Gray Apr 21 '16 at 17:38
  • So the AMP-HTML Document will work flawlessly even when the script is not served from Google? Will the Google Search Console accept it as a valid AMP page? – Jonas Köritz Apr 21 '16 at 17:40
  • No, you must use the Google JS CDN script for it to be a valid AMP document. However, if you also need to make the document available to users with restricted internet access, you can serve that using your own method. That approach would be a variation of a `canonical url` for your managed network access. – Jay Gray Apr 21 '16 at 17:45
  • Feel free to post this as an answer ;) – Jonas Köritz Apr 21 '16 at 17:46

1 Answers1

0

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).

Jay Gray
  • 1,706
  • 2
  • 20
  • 36
  • Can one at least use subresource integrity in the script tag? – ibotty Apr 25 '16 at 07:59
  • Not exactly sure what you are asking. Would you show an example statement? AMP JS has parameters, so need to see your example to be able to answer. – Jay Gray Apr 25 '16 at 09:38
  • To not let the cdn tinker with the javascript file: https://hacks.mozilla.org/2015/09/subresource-integrity-in-firefox-43/ – ibotty Apr 25 '16 at 10:11
  • I believe this concept is possible. I have an example somewhere; lemme find it and I'll post back. – Jay Gray Apr 25 '16 at 10:20
  • Here is an example using a Bootstrap CDN to use Font Awesome: ``. Obviously, this is for a `` tag. As far as I know, you cannot qualify the Google ` – Jay Gray Apr 25 '16 at 11:03
  • Please see the first example in the post I linked. It's exactly that, a ` – ibotty Apr 25 '16 at 13:58
  • The real question is, whether google will still validate it, if the `script`'s `integrity` attribute is set. – ibotty Apr 25 '16 at 13:59
  • 1
    TTBOMK, you cannot add an `integrity` attribute to the Google CDN ` – Jay Gray Apr 25 '16 at 20:25
  • That kind-of sucks. Thanks for the answer! – ibotty Apr 26 '16 at 18:53