Created
June 5, 2019 10:05
-
-
Save kaknut/efc000a8761b7d01b64fcf1f0ab0686c 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 | |
// 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