diff --git a/src/app/Coriolis.jsx b/src/app/Coriolis.jsx index 1bfde1af..3f1f7159 100644 --- a/src/app/Coriolis.jsx +++ b/src/app/Coriolis.jsx @@ -344,36 +344,34 @@ export default class Coriolis extends React.Component { }); } if ('serviceWorker' in navigator) { - window.addEventListener('load', () => { - // Your service-worker.js *must* be located at the top-level directory relative to your site. - // It won't be able to control pages unless it's located at the same level or higher than them. - // *Don't* register service worker file in, e.g., a scripts/ sub-directory! - // See https://github.com/slightlyoff/ServiceWorker/issues/468 - const self = this; - register('/service-worker.js', { - ready (registration) { - console.log('Service worker is active.') - }, - registered (registration) { - console.log('Service worker has been registered.') - }, - cached (registration) { - console.log('Content has been cached for offline use.') - }, - updatefound (registration) { - console.log('New content is downloading.') - }, - updated (registration) { - self.setState({ appCacheUpdate: true }); - console.log('New content is available; please refresh.') - }, - offline () { - console.log('No internet connection found. App is running in offline mode.') - }, - error (error) { - console.error('Error during service worker registration:', error) - } - }); + // Your service-worker.js *must* be located at the top-level directory relative to your site. + // It won't be able to control pages unless it's located at the same level or higher than them. + // *Don't* register service worker file in, e.g., a scripts/ sub-directory! + // See https://github.com/slightlyoff/ServiceWorker/issues/468 + const self = this; + register('/service-worker.js', { + ready (registration) { + console.log('Service worker is active.') + }, + registered (registration) { + console.log('Service worker has been registered.') + }, + cached (registration) { + console.log('Content has been cached for offline use.') + }, + updatefound (registration) { + console.log('New content is downloading.') + }, + updated (registration) { + self.setState({ appCacheUpdate: true }); + console.log('New content is available; please refresh.') + }, + offline () { + console.log('No internet connection found. App is running in offline mode.') + }, + error (error) { + console.error('Error during service worker registration:', error) + } }); } window.onerror = this._onError.bind(this);