原理

使用可见性以及预取数据,同时充分利用浏览器的空闲时间,主要是解析href 以通过代码的选项指定需要加载的数据,当然其中
也添加了好多灵活的控制参数,方便我们使用,而且代码很小,压缩之后也就1kb

运行使用了docker

version: "3"
services:
web:
image: nginx
volumes:
- "./:/usr/share/nginx/html/"
ports:
- "8080:80"

基本使用

  • 基本代码结构
<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
</head> <body>
<div class="h-c-header__initiative-logo h-c-header__initiative-logo--no-margin">
<a href="2.html" data-analytics='{
"category": "navigation",
"action": "header",
"label": "navlink: home"
}'
class="h-c-header__initiative-logo-link uni-click-tracker">
<span class="h-c-header__initiative-logo-text"> The Keyword</span>
</a>
</div>
<a href="static/js/login.js"></a>
<div id="landing-components" data-scripts='[
{ "url": "4.js",
"options": {
"async": true,
"defer": true
}
},
{ "url": "static/js/login.js",
"options": {
"async": true,
"defer": true
}
}
]'></div> <div id="userlogin"></div>
<input type="button" value="click load" onclick="load()" />
<iframe id="myhtml">
default content
</iframe>
<script type="text/javascript">
var scripts = document.querySelector("#landing-components").getAttribute('data-scripts');
scripts = JSON.parse(scripts);
scripts.forEach(function (scriptObj) {
var s = document.createElement('script');
s.async = scriptObj.options.async;
s.defer = scriptObj.options.defer;
s.src = scriptObj.url;
document.head.appendChild(s);
});
</script>
<script src="https://unpkg.com/quicklink@1.0.0/dist/quicklink.umd.js"></script> <script>
window.addEventListener('load', function () {
quicklink({});
}); function load() {
var content = document.getElementById("myhtml")
content.src = "2.html"
}
</script>
</body> </html>

效果测试

通过chrome 的调试可以看出数据已经进行加载了

参考资料

https://github.com/rongfengliang/quicklink-learning
https://github.com/GoogleChromeLabs/quicklink
https://github.com/w3c/IntersectionObserver

 
 
 
 

quicklink 基本使用的更多相关文章

  1. UWP学习记录12-应用到应用的通信

    UWP学习记录12-应用到应用的通信 1.应用间通信 “共享”合约是用户可以在应用之间快速交换数据的一种方式. 例如,用户可能希望使用社交网络应用与其好友共享网页,或者将链接保存在笔记应用中以供日后参 ...

  2. Axure RP介绍

    1.什么是原型设计?产品原型设计(Prototype Design)最基础的工作,就是结合批注.大量的说明以及流程图画框架图WireFrame,将自己的产品原型完整而准确的表述给 UI.UE.程序工程 ...

  3. 重新想象 Windows 8 Store Apps (39) - 契约: Share Contract

    [源码下载] 重新想象 Windows 8 Store Apps (39) - 契约: Share Contract 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之  ...

  4. WP7:模拟开始屏幕Tile漂动效果

    在WP7手机的开始屏幕,如果你Hold住某一个瓷贴,就会发现除了你按住的那个瓷贴其他全部下沉半透明,然后开始在不停地漂来漂去~~今天来模仿一下这个效果.新建一个项目,然后在Grid里放一个ListBo ...

  5. 快速构建Windows 8风格应用15-ShareContract构建

    原文:快速构建Windows 8风格应用15-ShareContract构建 本篇博文主要介绍共享数据包.如何构建共享源.如何构建共享目标.DataTransferManager类. 共享数据包 Da ...

  6. win10 uwp App-to-app communication 应用通信

    这篇文章都是乱说的,如果觉得有不好的,可以发我邮箱 应用之间需要相互的发送信息,就是我们经常用的分享 有个人看到一个网页很好,于是就希望把这个网页发送到邮件,那么这样的话就是使用应用通信. 因为每个应 ...

  7. Axure RP 介绍

    原型设计是将想法转变为设计过程中至关重要的一环.经常有设计师小伙伴可能会问到,“哪个原型设计工具是最好的呢”?实际上这是一种错误的提问方式,尤其是在当下原型工具种类繁多,针对不同需求各有优势的大环境中 ...

  8. 背水一战 Windows 10 (100) - 应用间通信: 分享

    [源码下载] 背水一战 Windows 10 (100) - 应用间通信: 分享 作者:webabcd 介绍背水一战 Windows 10 之 应用间通信 分享 示例1.本例用于演示如何开发一个分享的 ...

  9. centos installation of matlab R2015b

    the source of installation is in the website: http://blog.csdn.net/hejunqing14/article/details/50265 ...

随机推荐

  1. VSTO:使用C#开发Excel、Word【5】

    <Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath >——By Eric C ...

  2. Cracking The Coding Interview4.3

    //Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal h ...

  3. ubuntu下修改文件权限

    参考:https://www.cnblogs.com/viviwind/archive/2012/08/02/2619451.html 常用方法如下: sudo chmod 600 ××× (只有所有 ...

  4. bootstrapValidator常用验证规则总结

    bootstrapValidator常用验证规则总结 一 .bootstrapValidator引入 在使用bootstrapValidator前我们需要引入bootstrap和bootstrapVa ...

  5. CodeForces ~ 996

    Allen has a LOT of money. He has nn dollars in the bank. For security reasons, he wants to withdraw ...

  6. netty源码理解(二) serverstrap.bind()

    eventloop是一个线程,里面有一个executor封装了一个线程工厂,在启动的时候启动一个线程,传入的实现了runnable的内部类,里面调用了eventloop的run方法.

  7. 高级数据类型--列表[list]

    List(列表) 是 Python 中使用 最频繁 的数据类型,在其他语言中通常叫做 数组,专门用于存储 一串 信息,列表用 [] 定义,数据 之间使用 , 分隔,列表的 索引 从 0 开始. nam ...

  8. 关于时间戳截取的隐藏bug

    之前写时间戳,要截取后六位 原写法: function timeStamp() { const date = new Date() const month = date.getMonth() + 1 ...

  9. Word2Vec实现原理(Hierarchical Softmax)

    由于word2vec有两种改进方法,一种是基于Hierarchical Softmax的,另一种是基于Negative Sampling的.本文关注于基于Hierarchical Softmax的改进 ...

  10. MySql:触发器

    触发器 一.触发器的定义: 触发器是个特殊的存储过程,不同的是,执行存储过程要使用CALL语句来调用,而触发器的执行不需要使用CALL语句来调用,也不需要手工启动,只要当一个预定的事件发生时,就会被M ...