之前是否激活了ServiceWorker?

时间:2017-08-17 13:20:36

标签: javascript google-chrome service-worker

是否可以告诉浏览器提前启动ServiceWorker激活和安装阶段?

当我查看我们在Chrome中的性能时,您可以在下面看到,工作程序在前1.5秒内加载,但激活不是在3.3秒之前!有没有办法告诉浏览器尽快安装和激活ServiceWorker?

When I look at our performance in Chrome,

这是我的ServiceWorker代码:

self.addEventListener('install', (event) => {
  // Bypass the waiting lifecycle stage,
  // Just in case there's an older version of this SW registration.
  event.waitUntil(self.skipWaiting());
});

self.addEventListener('activate', (event) => {
  // Take control of all pages under this SW's scope immediately,
  // Instead of waiting for reload/navigation.
  event.waitUntil(self.clients.claim());
});

0 个答案:

没有答案