- 可视窗口的资源加载
- 空闲线程资源
- 自动监测网络情况决定是否加载资源
- ....
const observer = IntersectionObserver 判断某个元素是否进入了视野
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
const link = entry.target;
console.log(link)
})
})
Array.from(document.querySelectorAll("a"), link => {
observer.observe(link);
})
- 通过拦截网络请求,使得网站运行的更快,或者在离线情况下,依然可以执行,也作为后台功能的基础,比如消息推送和背景同步
- https注意
- 属于js Worker,不能直接接触Dom,通过postMessage接口和页面通信
installing -》 installed activating --》activeted
Redundant(注册失败)
workbox-webpack-plugin : https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin