问题
I want to host the javascript myself, to make sure I know the code being distributed to my users. Is it possible? Would there be consequences?
(i'm assuming the javascript can be built from https://github.com/ampproject/amphtml)
回答1:
Basically, AMP is a way to build web pages for static content that render fast. AMP in action consists of three different parts:
AMP HTML is HTML with some restrictions for reliable performance and some extensions for building rich content beyond basic HTML. The AMP JS library ensures the fast rendering of AMP HTML pages. The Google AMP Cache can be used to serve cached AMP HTML pages.
AFAIK, AMP Project JavaScript is only accessible using the https://cdn.ampproject.org
URL.
JavaScript is powerful, it can modify just about every aspect of the page, but it can also block DOM construction and delay page rendering (see also Adding interactivity with JavaScript). To keep JavaScript from delaying page rendering, AMP allows only asynchronous JavaScript.
AMP pages can’t include any author-written JavaScript. Instead of using JavaScript, interactive page features are handled in custom AMP elements. The custom AMP elements may have JavaScript under the hood, but they’re carefully designed to make sure they don’t cause performance degradation.
Also in my older post regarding Is there a way to use an alternate CDN for including the main JavaScript file AMP needs.
Hope this helps.
来源:https://stackoverflow.com/questions/41840889/is-it-ok-to-self-host-the-amp-project-javascript