Html5 什么是prefetch/prerender?介绍Html5 中prefetch/prerender


本文摘自PHP中文网,作者零下一度,侵删。

文章标题写,为Affiliate而生 其实是夸张写法,

prerender / prefetch

其实是为了提升网页加载速度而但是一直通过预加载来实现,提升用户感受的方式,例如用户在首页停留2s, 而这2s里面我们就已经加载了一个用户可能要打开的页面,那么用户打开的速度会非常快. 给用户的感受也是极好的

HTML5 Prerender / Prefetch名词解释

prefetch usage:

1

It should be used for fetching and caching resources for later user navigation as per the official HTML5 spec (i.e. prefetching a css file to be used in a page which highly likely to be used by the user in his upcoming navigation). Supported in Chrome, Firefox & IE.

简单说就是缓存下一个网页的资源,是HTML5的新特性, 支持的浏览器有Chrome(13以后), Firefox, IE 11

prerender usage:

1

It should be used for prerendering a complete page that the user will highly likely navigate to it in his upcoming navigation (i.e. like prerendering the next article where it is highly likely that the user will click on “next article” button). Supported only in Chrome & IE.

Prerender是Google的一个发明,正在提升用户减少用户在加载时的等待, 通过最相近匹配原则来加载例如“下一页”的文章., 例如最佳推荐,当用户访问A页面的时候, 用户最可能访问的下一个页面上B 那么就预加载B页面, 以达到提升加载速度的效果, 支持的浏览器有Chrome , IE11

使用方法

1

2

is actually part of the HTML 5 spec.

appears to be Google doing their own thing.

第一中方法是 将以上链接添加到xxx

第二种方法是 使用JS代码注入方式;

1

2

3

4

5

var myHead = document.getElementsByTagName(‘head’)[0];

var myLink = document.createElement(‘link’);

myLink.setAttribute(‘rel’, ‘prerender’);

myLink.setAttribute(‘href’, ‘http://apple.com/ipad’);

myHead.appendChild(myLink);

或者使用Jquery方法:

1

$(“head”).append(‘www.guoli.biz/’);

有什么问题,欢迎留言提问

【相关推荐】

1. 免费h5在线视频教程

2. HTML5 完整版手册

3. php.cn原创html5视频教程

以上就是Html5 什么是prefetch/prerender?介绍Html5 中prefetch/prerender的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

关于HTML5中p和span标签的介绍

HTML5实现留言板的代码实例分享

利用html实现一个个人信息表的网页(代码实例)

HTML5大文件上传技术分享

移动端h5页面尺寸大小

HTML5的七大优势“逼宫”app

了解一下HTML5中新增加的标签

html如何定义错误提示

jquery方法的总结(附示例)

h5 canvas api中drawimage(图像进行缩放或裁剪)的使用实例

更多相关阅读请进入《HTML5》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...