regexper-static/src/service-worker.js

12 lines
447 B
JavaScript
Raw Normal View History

2018-02-10 21:08:42 +00:00
if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
2018-02-10 23:10:30 +00:00
console.log('SW registered:', registration); // eslint-disable-line no-console
2018-02-10 21:08:42 +00:00
})
.catch(registrationError => {
2018-02-10 23:10:30 +00:00
console.log('SW registration failed:', registrationError); // eslint-disable-line no-console
2018-02-10 21:08:42 +00:00
});
});
}