Last active
October 8, 2017 12:37
-
-
Save olegkorol/3ee633b0ddd49a87e5052d625f6a746e to your computer and use it in GitHub Desktop.
Script to unregister a registered Service Worker on the browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkForSWs() { | |
console.log('I will look for registered SW\'s now...') | |
navigator.serviceWorker.getRegistrations() | |
.then(sws => { | |
if (sws[0]) { | |
console.log('Found a registered SW:', sws[0], '\n Will proceed to unregister...'); | |
sws[0].unregister(); | |
console.log('Done.') | |
} else { | |
console.log('No registered SW\'s were found.') | |
} | |
}) | |
.catch(err => { | |
console.error('An error occurred while searching for SW\'s:', err); | |
}) | |
} | |
checkForSWs(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment