Skip to content

Commit

Permalink
fix(workbox): faster service worker register
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Nov 17, 2017
1 parent 7ae84a9 commit 07524a2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/workbox/templates/sw.plugin.js
@@ -1,14 +1,11 @@
window.onNuxtReady(() => {
if (!('serviceWorker' in navigator)) {
console.warn('Service workers are not supported.')
return
}

if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('<%= options.swURL %>', {
scope: '<%= options.swScope %>'
}).then(function(registration) {
window.$sw = registration
}).catch(function(error) {
console.error('Service worker registration failed:', error);
});
})
console.error('Service worker registration failed:', error)
})
} else {
console.warn('Service workers are not supported.')
}

0 comments on commit 07524a2

Please sign in to comment.