Skip to content

Instantly share code, notes, and snippets.

@mrienstra
Created February 4, 2018 22:10
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save mrienstra/9c60a76009480e2240770dadb2fb96fe to your computer and use it in GitHub Desktop.
Save mrienstra/9c60a76009480e2240770dadb2fb96fe to your computer and use it in GitHub Desktop.
Unregister service workers, verbose
navigator.serviceWorker.getRegistrations().then(function (registrations) {
if (!registrations.length) {
console.log('No serviceWorker registrations found.')
return
}
for(let registration of registrations) {
registration.unregister().then(function (boolean) {
console.log(
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
(registration.waiting ? ' .waiting.scriptURL = ' + registration.waiting.scriptURL + '\n' : '') +
(registration.active ? ' .active.scriptURL = ' + registration.active.scriptURL + '\n' : '') +
' .scope: ' + registration.scope + '\n'
)
})
}
})
@landsman
Copy link

thanks!

@michaelaflores
Copy link

Ty 🙏

@asheroto
Copy link

asheroto commented Sep 4, 2022

You can also unregister all service workers by going to

chrome://serviceworker-internals/

and running this in console

document.querySelectorAll(".unregister").forEach(item=>item.click())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment