Last active
April 1, 2016 09:24
-
-
Save the-unsoul/edb879da66d3816fe9b68815bc1b4a71 to your computer and use it in GitHub Desktop.
This cheat sheet collecting information of quick snippet of Service Worker from many source ( StackOverflow, Mozila Developer Network..)
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
// Registering | |
navigator.serviceWorker.register('./path_to_your_worker.js', { | |
scope: './base_url_of_the_web_app/' | |
}).then(function(registration) { | |
// Do soemthing with registration... | |
}, function(error) { | |
console.log('Failed to install:' + error); | |
}); | |
// Unregistering (uninstall) all | |
navigator.serviceWorker.getRegistrations().then(function(registrations) { | |
for(let registration of registrations) { | |
registration.unregister() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment