1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 09:13:19 +01:00

self destroying service worker

This commit is contained in:
Matthias Kretschmann 2022-11-16 21:39:20 +00:00
parent e60e54ff13
commit 3e777545b5
Signed by: m
GPG Key ID: 606EEEF3C479A91F

15
public/sw.js Normal file
View File

@ -0,0 +1,15 @@
// https://github.com/NekR/self-destroying-sw
self.addEventListener('install', function (e) {
self.skipWaiting()
})
self.addEventListener('activate', function (e) {
self.registration
.unregister()
.then(function () {
return self.clients.matchAll()
})
.then(function (clients) {
clients.forEach((client) => client.navigate(client.url))
})
})