Created
June 14, 2019 10:40
-
-
Save kaknut/764c23c7b91bf7cca3d13f996acda339 to your computer and use it in GitHub Desktop.
This file contains 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
//Add this below content to your HTML page, or add the js file to your page at the very top to register service worker | |
if (navigator.serviceWorker.controller) { | |
console.log('active service worker found, no need to register') | |
} else { | |
//Register the ServiceWorker | |
navigator.serviceWorker.register('/service-worker.js', { | |
scope: './' | |
}).then(function(reg) { | |
console.log('Service worker has been registered for scope:'+ reg.scope); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment