2017-09-14
laco
if ('serviceWorker' in navigator) {
// register service worker
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
registration.update()
.then(() => {
registration.unregister();
});
});
}
Get the page under control
self.addEventListener("activate", (event) => {
event.waitUntil(
self.clients.claim()
);
});
Activate worker immediately
self.addEventListener("install", (event) => {
event.waitUntil(
self.skipWaiting()
);
});