diff options
author | XhmikosR <xhmikosr@gmail.com> | 2017-07-16 16:54:09 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2017-08-15 14:35:36 +0300 |
commit | 20abbc3c16d39ad92fbf0b497a3690967764a1fd (patch) | |
tree | b165349514270997b095a9922ba4bb240ea1ed59 /assets/js | |
parent | e9323459ab226d9eb0d15217707c1ce12cf490eb (diff) |
Register a service worker.
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/src/pwa.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/assets/js/src/pwa.js b/assets/js/src/pwa.js new file mode 100644 index 0000000000..95ee339482 --- /dev/null +++ b/assets/js/src/pwa.js @@ -0,0 +1,15 @@ +/* eslint no-console:off */ + +(function setupSW() { + 'use strict' + + if ('serviceWorker' in navigator) { + window.addEventListener('load', function () { + navigator.serviceWorker.register('/sw.js').then(function (registration) { + console.log('ServiceWorker registration successful with scope: ', registration.scope) + }).catch(function (err) { + console.log('ServiceWorker registration failed: ', err) + }) + }) + } +}()) |