问题
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.
回答1:
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.
回答2:
The JS should no longer be blocked in China.
回答3:
Cloudflare now provides an alternative to Google's AMP cache: https://blog.cloudflare.com/accelerated-mobile/
来源:https://stackoverflow.com/questions/39312339/is-it-possible-to-use-an-alternate-cdn-for-amp-as-ampproject-org-is-blocked-in-c