How can I implement AMP in angular/ionic website?

2019-04-06 22:21发布

问题:

Recently i've heard about the Accelerated Mobile Pages project, and read some info about it.

I wonder how to implement it for existing website that is built upon Ionic and Angular?

回答1:

Basically there is no nearly possible solution to do that. If you check the doc here.

Keep all third-party JavaScript out of the critical path

Third-party JS likes to use synchronous JS loading. They also like to document.write more sync scripts. For example, If you five ads, and each does three sync loads, with a 1 second latency connection, you’re in 18 seconds of load time just for JS loading.

AMP pages allow third-party JavaScript but only in sandboxed iframes. By banning them into iframes, they can’t block execution of the main page. Even if they trigger multiple style re-calculations, their tiny iframes have very little DOM.

Style-recalculations and layouts are typical to DOM size, so the iframe recalculations are very fast compared to a recalculating styles and layout for the page.