-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(workbox): faster service worker register
- Loading branch information
Pooya Parsa
committed
Nov 17, 2017
1 parent
7ae84a9
commit 07524a2
Showing
1 changed file
with
6 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.') | ||
} |