Created
March 6, 2020 06:43
-
-
Save matthewhartman/cfbb68a0e06aa7ab91db665ff536a390 to your computer and use it in GitHub Desktop.
Basic Service Worker (needs corresponding sw.js on root)
This file contains hidden or 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
// Service Worker | |
(function(serviceWorker) { | |
if ('serviceWorker' in navigator) { | |
window.addEventListener('load', function() { | |
navigator.serviceWorker.register('/sw.js').then(function(registration) { | |
console.log('ServiceWorker registration successful with scope: ', registration.scope) | |
}, function(err) { | |
console.log('ServiceWorker registration failed: ', err) | |
}) | |
}) | |
} | |
})(window.serviceWorker = window.serviceWorker || {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment