pwa.js 552 Bytes
Newer Older
XhmikosR's avatar
XhmikosR committed
1
2
3
4
5
6
7
/* eslint no-console:off */

(function setupSW() {
  'use strict'

  if ('serviceWorker' in navigator) {
    window.addEventListener('load', function () {
XhmikosR's avatar
XhmikosR committed
8
      navigator.serviceWorker.register('/sw.js').then(function (registration) { // eslint-disable-line compat/compat
XhmikosR's avatar
XhmikosR committed
9
10
11
12
13
        console.log('ServiceWorker registration successful with scope: ', registration.scope)
      }).catch(function (err) {
        console.log('ServiceWorker registration failed: ', err)
      })
    })
14
15
  } else {
    console.log('Service workers are not supported.')
XhmikosR's avatar
XhmikosR committed
16
17
  }
}())