Skip to content

Instantly share code, notes, and snippets.

@kaknut kaknut/main.js
Created Jun 5, 2019

Embed
What would you like to do?
// Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
// Check compatibility for the browser we're running this in
if ("serviceWorker" in navigator) {
if (navigator.serviceWorker.controller) {
console.log("NutPanda: active service worker found, no need to register");
} else {
// Register the service worker
navigator.serviceWorker
.register("sw.js", {
scope: "./"
})
.then(function (reg) {
console.log("NutPanda 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
You can’t perform that action at this time.