if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('sw.js').then((reg) => {
    const status = reg.installing ? 'installing' : reg.waiting ? 'installed' : reg.active ? 'active' : '???';
    console.log('Service worker ' + status);
  }).catch((error) => {
    console.log('Registration failed with ' + error);
  });
}