pwa.js 545 B

1234567891011121314151617
  1. /* eslint no-console:off */
  2. (function () {
  3. 'use strict'
  4. if ('serviceWorker' in navigator) {
  5. window.addEventListener('load', function () {
  6. navigator.serviceWorker.register('/sw.js').then(function (registration) { // eslint-disable-line compat/compat
  7. console.log('ServiceWorker registration successful with scope: ', registration.scope)
  8. }).catch(function (err) {
  9. console.log('ServiceWorker registration failed: ', err)
  10. })
  11. })
  12. } else {
  13. console.log('Service workers are not supported.')
  14. }
  15. }())