serviceWorkerRegister.js 370 B

123456789
  1. if ('serviceWorker' in navigator) {
  2. window.addEventListener('load', function () {
  3. navigator.serviceWorker.register('/serviceWorker.js').then(function (registration) {
  4. console.log('ServiceWorker registration successful with scope: ', registration.scope);
  5. }, function (err) {
  6. console.error('ServiceWorker registration failed: ', err);
  7. });
  8. });
  9. }