Skip to content

Commit

Permalink
Register a service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantha committed Aug 14, 2018
1 parent 356851c commit e933b1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@
<body>
<section id="owncloud"></section>
<script data-main="core/js/core.bundle.js" src="node_modules/requirejs/require.js"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
// console.log(`Service Worker registered! Scope: ${registration.scope}`);
})
.catch(err => {
// console.log(`Service Worker registration failed: ${err}`);
});
});
}
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable no-undef,no-console */

importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.3.1/workbox-sw.js');

// workbox.routing.registerRoute(
// new RegExp('http://localhost:4000/.*'),
// workbox.strategies.cacheFirst()
// );

0 comments on commit e933b1e

Please sign in to comment.