Skip to content

Instantly share code, notes, and snippets.

Last active January 28, 2022 12:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Steph-crown/bff38c0e1b14a3a5060aaabc77456081 to your computer and use it in GitHub Desktop.
A script to register a service worker
// Checks if we can use serviceWorker.
if ("serviceWorker" in navigator) {
.then((registration) => {
// The registration wass successful
console.log("Service worker registered");
.catch((err) => {
// The registration failed
console.log("Sercvice worker registration failed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment