instant.page 可以预加载用户想访问的页面,当用户真正点击链接后,就会直接从缓存中读取,以此提升网站的访问速度。
instant.page 官网:https://instant.page/
这是一段来自官网的介绍:
On desktop Before a user clicks on a link, they hover their mouse over that link. When a user has hovered for 65 ms there is one chance out of two that they will click on that link, so instant.page starts preloading at this moment, leaving on average over 300 ms for the page to preload.
Another option is to load the pages when the user starts pressing their mouse without preloading. This makes for zero unused requests while still improving page loads by 80 ms on average.
You can also preload on hover or as soon as a link is visible and trigger the click when the user starts pressing their mouse, making your pages the fastest in the world.
On mobile A user starts touching their display before releasing it, leaving on average 90 ms for the page to preload.
Another option is to preload links as soon as they’re visible.
大致意思应该是:
效果如下
1.使用官方脚本 只要把这行代码添加到网站的 标签之前即可。(由于脚本托管在国外,只建议国外的朋友使用,国内的朋友加载官方的资源会比较慢哦)
<script src="//instant.page/5.1.0" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>
2.自托管文件 (推荐) 只需将下面下载地址里的 js 文件 上传到自己服务器,然后在 标签之前根据路径添加下面的代码即可(强烈建议服务器在国内的朋友使用)
<script src="`存放路径`/instantpage.js" type="module"></script>
3.公共 CDN 资源 (强烈推荐) 只要把这行代码添加到网站的 标签之前即可。(由于文件全球 CDN,所以强烈建议使用,节省服务器资源) 代码一(较快)
<script src="https://cdn.jsdelivr.net/gh/instantpage/instant.page@master/instantpage.js" type="module"></script>
代码二(快速)
<script src="https://cdn.jsdelivr.net/npm/instant.page@5.1.0/instantpage.js" type="module"></script>
Github 官方下载 https://github.com/instantpage/instant.page
度盘下载 Download 网盘文件提取码:g8pg