Skip to content

Instantly share code, notes, and snippets.

@the-unsoul
Last active April 1, 2016 09:24
Show Gist options
  • Save the-unsoul/edb879da66d3816fe9b68815bc1b4a71 to your computer and use it in GitHub Desktop.
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..)
// 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