Is there a way to use an alternate CDN for including the main JavaScript file AMP needs? Can a different URL than https://cdn.ampproject.org/v0.js
be used? Are there plans to open this up a bit more by allowing other CDNs that aren't blocked in China, etc?
Using several of the top proxies returned from a web search, it appears that ampproject.org
is blocked in China. This isn't too surprising as other Google properties are blocked.
Edit: I should mention I tried copying the file and running it locally, but the AMP validator throws an error when I try that.
The JS should no longer be blocked in China.
Cloudflare now provides an alternative to Google's AMP cache: https://blog.cloudflare.com/accelerated-mobile/
Matt Mower posted a gist explaining how to self-host AMP framework. That worked for me.
summary of his post:
src
attributes. I.E: <script async src="https://cdn.ampproject.org/v0.js"></script>
→ <script async src="<path_to_amp_files>/v0.js"></script>
runtime-host
meta tag. Prepend <meta name="runtime-host" content="<path_to_amp_files>">
before any script tags in head element.amp-geo-api
in the gist.Unfortunately, I think the source file of the main Javascript the AMP need is only accessible using the https://cdn.ampproject.org
URL.
According to the blog "Getting started with AMP Html, accelerated mobile pages"
AMP does this by creating new rules for bottlenecks: JavaScript and html elements that are considered slow are prohibited. JavaScript is only allowed using libraries provided by the CDN of Google itself.
Also in their official web page:
Our goal with AMP HTML is reliable performance, so we designed it to be easily cacheable by content delivery networks (CDNs). Google is offering a service that delivers AMP HTML documents given their URL through its CDN. Others can use this service or make their own or serve AMP HTML pages from a plain-old-web-server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With