Skip to content

Instantly share code, notes, and snippets.

@puncoz
Created July 15, 2019 17:16
Show Gist options
  • Save puncoz/d4cd6c7ef1fee69c0f5bbdd8f60af907 to your computer and use it in GitHub Desktop.
Save puncoz/d4cd6c7ef1fee69c0f5bbdd8f60af907 to your computer and use it in GitHub Desktop.
Service worker registering in index.html, Backend Knowledge Sharing #8, https://blog.yipl.com.np/
...
<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js").then((registration) => {
console.log("Service worker registered successfully with scope: ", registration.scope)
}).catch((error) => {
console.error("Service worker registration failed.", error)
})
} else {
console.info("Your browser does not support the Service-Worker!")
}
</script>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment