if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/service-worker.js').then(function(registration) { console.log('ServiceWorker for offline registered!', registration.scope); }); }