if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('./service-worker.js', {scope: './'})
    .catch(function(error) {
      alert('Error registering service worker:'+error);
    });
} else {
  alert('service worker not supported');
}
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('./service-worker.js', {scope: './'})
    .catch(function(error) {
      console.error('Error registering service worker:'+error);
    });
} else {
  console.log('service worker not supported');
}

Use console.error and console.log instead of alert
Use console.error and console.log instead of alert
