Skip to content

Instantly share code, notes, and snippets.

@reecelucas
Created July 2, 2018 20:49
Show Gist options
  • Save reecelucas/19276f9dda7ec83beffafdfb4837568b to your computer and use it in GitHub Desktop.
Save reecelucas/19276f9dda7ec83beffafdfb4837568b to your computer and use it in GitHub Desktop.
Register a service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker
.register('path/to/service-worker.js')
.then(registration => {
console.log('SW registered: ', registration);
})
.catch(registrationError => {
console.log('SW registration failed: ', registrationError);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment