Skip to content

Instantly share code, notes, and snippets.

@paul-millar
Created April 3, 2025 21:53
Show Gist options
  • Save paul-millar/5fbe5b84399a88c1191449bf124f32c7 to your computer and use it in GitHub Desktop.
Save paul-millar/5fbe5b84399a88c1191449bf124f32c7 to your computer and use it in GitHub Desktop.
sw.js
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))
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment