tldraw/apps/dotcom/public/sw.js

19 lines
552 B
JavaScript
Raw Normal View History

// Self-destroying service worker
// Taken from https://www.benjaminrancourt.ca/how-to-remove-a-service-worker/
// Inspired from https://github.com/NekR/self-destroying-sw
self.addEventListener("install", (event) => {
self.skipWaiting();
});
self.addEventListener("activate", (event) => {
self.registration
.unregister()
.then(() => self.clients.matchAll())
.then((clients) => {
clients.forEach((client) => {
if (client.url && "navigate" in client) {
client.navigate(client.url);
}
});
});
});