add fetch script to same file

This commit is contained in:
Anthony 2021-06-02 21:50:47 +02:00 committed by Jeremy Kauffman
parent 9798bf14f4
commit 304bb3a999
2 changed files with 6 additions and 5 deletions

View file

@ -1,3 +0,0 @@
self.addEventListener('fetch', function(event) {
// console.log(`start server worker`); // service worker started
});

View file

@ -1,7 +1,11 @@
// register service worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./public/pwa/serviceWorker.js').then(function(reg) {
// console.log('Successfully registered service worker', reg);
navigator.serviceWorker.register('./serviceWorker.js').then(function(reg) {
// reg.scope must be '/' to allow '/' as start url
}).catch(function(err) {
// console.warn('Error whilst registering service worker', err);
});
}
// used to fetch the manifest file
self.addEventListener('fetch', () => {});