美文网首页HTML5HTML5学习笔记Affiliate Marketing
技术干货|Html5 prefetch/prerender提前加

技术干货|Html5 prefetch/prerender提前加

作者: 数据科学 | 来源:发表于2017-05-08 23:54 被阅读100次
    程序人生

    有1周没有写Affiliate的文章了, 今天写一片技术稿来安慰下果粒圈的朋友.

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

    prerender / prefetch

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

    HTML5 Prerender / Prefetch名词解释

    prefetch usage:

    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:

    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

    使用方法

    Prefetchis  - actually part of the HTML 5 spec.  

    Prerender   -    appears to be Google doing their own thing.  

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

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

    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方法:

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

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

    原文地址: http://www.guoli.biz/24322.html

    果粒圈 :http://www.guoli.biz

    相关文章

      网友评论

        本文标题:技术干货|Html5 prefetch/prerender提前加

        本文链接:https://www.haomeiwen.com/subject/fnavtxtx.html