Skip to content

Instantly share code, notes, and snippets.

@mciastek
Created January 29, 2017 13:09
Show Gist options
  • Select an option

  • Save mciastek/30ea15691c7a95fabb848afb5bd7b39a to your computer and use it in GitHub Desktop.

Select an option

Save mciastek/30ea15691c7a95fabb848afb5bd7b39a to your computer and use it in GitHub Desktop.
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js')
.then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(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