Skip to content

Instantly share code, notes, and snippets.

@DaveHudson
Created February 26, 2018 19:11
Show Gist options
  • Save DaveHudson/af9da426b752366c933c6c36cde4b633 to your computer and use it in GitHub Desktop.
Save DaveHudson/af9da426b752366c933c6c36cde4b633 to your computer and use it in GitHub Desktop.
Add Service Worker to HTML
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(function (registration) {
console.log('Service Worker registration successful with scope: ', registration.scope)
})
.catch(function (err) {
console.log('Service Worker registration failed: ', err)
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment