quicklink 基本使用
原理
使用可见性以及预取数据,同时充分利用浏览器的空闲时间,主要是解析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 基本使用的更多相关文章
- UWP学习记录12-应用到应用的通信
UWP学习记录12-应用到应用的通信 1.应用间通信 “共享”合约是用户可以在应用之间快速交换数据的一种方式. 例如,用户可能希望使用社交网络应用与其好友共享网页,或者将链接保存在笔记应用中以供日后参 ...
- Axure RP介绍
1.什么是原型设计?产品原型设计(Prototype Design)最基础的工作,就是结合批注.大量的说明以及流程图画框架图WireFrame,将自己的产品原型完整而准确的表述给 UI.UE.程序工程 ...
- 重新想象 Windows 8 Store Apps (39) - 契约: Share Contract
[源码下载] 重新想象 Windows 8 Store Apps (39) - 契约: Share Contract 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 ...
- WP7:模拟开始屏幕Tile漂动效果
在WP7手机的开始屏幕,如果你Hold住某一个瓷贴,就会发现除了你按住的那个瓷贴其他全部下沉半透明,然后开始在不停地漂来漂去~~今天来模仿一下这个效果.新建一个项目,然后在Grid里放一个ListBo ...
- 快速构建Windows 8风格应用15-ShareContract构建
原文:快速构建Windows 8风格应用15-ShareContract构建 本篇博文主要介绍共享数据包.如何构建共享源.如何构建共享目标.DataTransferManager类. 共享数据包 Da ...
- win10 uwp App-to-app communication 应用通信
这篇文章都是乱说的,如果觉得有不好的,可以发我邮箱 应用之间需要相互的发送信息,就是我们经常用的分享 有个人看到一个网页很好,于是就希望把这个网页发送到邮件,那么这样的话就是使用应用通信. 因为每个应 ...
- Axure RP 介绍
原型设计是将想法转变为设计过程中至关重要的一环.经常有设计师小伙伴可能会问到,“哪个原型设计工具是最好的呢”?实际上这是一种错误的提问方式,尤其是在当下原型工具种类繁多,针对不同需求各有优势的大环境中 ...
- 背水一战 Windows 10 (100) - 应用间通信: 分享
[源码下载] 背水一战 Windows 10 (100) - 应用间通信: 分享 作者:webabcd 介绍背水一战 Windows 10 之 应用间通信 分享 示例1.本例用于演示如何开发一个分享的 ...
- centos installation of matlab R2015b
the source of installation is in the website: http://blog.csdn.net/hejunqing14/article/details/50265 ...
随机推荐
- win10环境下安装Ubantu双系统(超详解)
win10环境下安装Ubantu双系统 1.准备工作: 先去ubantu官网(https://www.ubuntu.com/download)去下载ubantu镜像.根据自己的实际情况选择32位的或者 ...
- SQL-31 获取select * from employees对应的执行计划
题目描述 获取select * from employees对应的执行计划 explain select * from employees explain 用于获得表的所有细节
- Java基础复习
java语言的一个核心:jdk, java development kits---面向开发人员jre, java Runtime Environment---服务器上 java虚拟机---(以字节码为 ...
- 循环神经网络-Dropout
dropout 是 regularization 方法,在rnn中使用方法不同于cnn 对于rnn的部分不进行dropout,也就是说从t-1时候的状态传递到t时刻进行计算时,这个中间不进行memor ...
- IasS,CasS,PasS,SasS的区别
IasS: (Infrastructure-as-a-Service(基础设施即服务)) 租用的是硬件,服务器,物理机等 CasS: (container as a Service) 容器服务 租用的 ...
- Java编程中必须了解 十几个代码段
向文件末尾添加内容 字符串有整型的相互转换 转字符串到日期 java.util.Date = java.text.DateFormat.getDateInstance().parse(date Str ...
- React native Configuration with name 'default' not found.
添加插件后出现异常 FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring ...
- centos7 安装mysql--python模块出现EnvironmentError: mysql_config not found和error: command 'gcc' failed with exit status 1
要想使python可以操作mysql 就需要MySQL-python驱动,它是python 操作mysql必不可少的模块. 下载地址:https://pypi.python.org/pypi/MySQ ...
- 【转载】 程序员制作996.icu网站抗议加班,你认为996能提高工作效率吗?
原文地址: https://zhidao.baidu.com/question/623053193192988612.html ------------------------------------ ...
- Failed to decode response: zlib_decode(): data error
/********************************************************************** * Failed to decode response: ...