Skip to content

Instantly share code, notes, and snippets.

@ketola
Created May 27, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ketola/e0b6bdd090c49414aa90ab64b90e2862 to your computer and use it in GitHub Desktop.
Save ketola/e0b6bdd090c49414aa90ab64b90e2862 to your computer and use it in GitHub Desktop.
Application registers the service worker
// check for service worker support in the browser
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment