Created
June 29, 2019 17:28
-
-
Save indreklasn/0718de3470383e38c5266637933ad1e1 to your computer and use it in GitHub Desktop.
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
if ('serviceWorker' in navigator) { | |
// attach event listener on page l aod | |
window.addEventListener('load', () => { | |
// register serviceWorker withthe [sw.js] file | |
navigator.serviceWorker.register('/sw.js').then(registration => { | |
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