Typecho 通过 instantpage.js 脚本预加载提升网站访问速度
在用户点击网站链接之前,他们将鼠标悬停在该链接上。当用户徘徊65毫秒时,他们将点击该链接有两个机会,因此 instant.page 此时开始预加载,平均超过 300 毫秒,以便页面预加载。
instant.page 是渐进式增强 - 对不支持它的浏览器没有影响。
原理就是通过捕捉鼠标悬浮的链接进行预加载。此脚本的加速指站内加速,但只会预加载 html 页面,不会加载图片等资源,所以不用担心与流量损耗等问题。
GitHub 地址:https://github.com/instantpage/instant.page
typecho 调用方法
把上述 Github链接文件 instantpage.js 下载之后上传到网站目录下;
在footer.php 文件 /body 标签前添加:
">
<script src="`存放路径`/instantpage.js" type="module"></script>
如:
">
<script src="https://s1.feiyubk.com/CDN/instantpage/instantpage3.0.0.js" type="module"></script>
本站托管instantpage.js资源:
https://s1.feiyubk.com/CDN/instantpage/instantpage5.1.0.js
https://s1.feiyubk.com/CDN/instantpage/instantpage5.0.1.js
https://s1.feiyubk.com/CDN/instantpage/instantpage5.0.0.js
https://s1.feiyubk.com/CDN/instantpage/instantpage3.0.0.js
https://s1.feiyubk.com/CDN/instantpage/instantpage2.0.1.js
https://s1.feiyubk.com/CDN/instantpage/instantpage2.0.0.js
https://s1.feiyubk.com/CDN/instantpage/instantpage1.3.1.js
https://s1.feiyubk.com/CDN/instantpage/instantpage1.3.0.js
https://s1.feiyubk.com/CDN/instantpage/instantpage1.2.2.js
https://s1.feiyubk.com/CDN/instantpage/instantpage1.2.1.js
https://s1.feiyubk.com/CDN/instantpage/instantpage1.2.0.js
BUG:使用此脚本后统计数据增加,因为预加载会被统计成正常浏览次数,期待官方解决
本站使用3.0.0版本
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »