-
-
Save chinhvo/e56b2a869715e07ec6a9046d47d9fa92 to your computer and use it in GitHub Desktop.
Register a Service Worker
This file contains hidden or 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
<script> | |
// Register the service worker | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('/service-worker.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); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment