Skip to content

Commit 07524a2

Browse files
author
Pooya Parsa
committedNov 17, 2017
fix(workbox): faster service worker register
1 parent 7ae84a9 commit 07524a2

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed
 

Diff for: ‎packages/workbox/templates/sw.plugin.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
window.onNuxtReady(() => {
2-
if (!('serviceWorker' in navigator)) {
3-
console.warn('Service workers are not supported.')
4-
return
5-
}
6-
1+
if ('serviceWorker' in navigator) {
72
navigator.serviceWorker.register('<%= options.swURL %>', {
83
scope: '<%= options.swScope %>'
94
}).then(function(registration) {
105
window.$sw = registration
116
}).catch(function(error) {
12-
console.error('Service worker registration failed:', error);
13-
});
14-
})
7+
console.error('Service worker registration failed:', error)
8+
})
9+
} else {
10+
console.warn('Service workers are not supported.')
11+
}

0 commit comments

Comments
 (0)
Please sign in to comment.