如何在角度/离子网站中实现AMP? [英] How can I implement AMP in angular/ionic website?

查看:147
本文介绍了如何在角度/离子网站中实现AMP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我听说过Accelerated Mobile Pages项目,并阅读了一些有关它的信息。

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?

推荐答案

基本上没有几乎可能的解决办法。如果您查看doc 这里

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


将所有第三方JavaScript排除在关键路径之外



第三方JS喜欢使用同步JS加载。他们还喜欢document.write更多同步脚本。例如,如果您有五个广告,并且每个广告都有三个同步加载,并且延迟时间为1秒,那么您加载时间仅为18秒。

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页面允许第三方JavaScript,但仅限沙盒iframe。通过禁止他们进入iframe,他们无法阻止主页的执行。即使它们触发多个样式重新计算,它们的小iframe也只有很少的DOM。

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.

样式重新计算和布局是DOM大小的典型值,因此iframe重新计算非常与重新计算页面的样式和布局相比较快。

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.

这篇关于如何在角度/离子网站中实现AMP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆