We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9ac592 commit 4fc8e4dCopy full SHA for 4fc8e4d
app.vue
@@ -22,9 +22,16 @@ if (!process.server) {
22
onMounted(() => {
23
if (typeof window !== 'undefined') {
24
if ('serviceWorker' in navigator) {
25
- window.addEventListener('load', function () {
+ const registerSw = () => {
26
+ console.debug(`Registering service worker at /${swPath}`)
27
navigator.serviceWorker.register(`/${swPath}`)
- })
28
+ }
29
+
30
+ if (document.readyState === 'complete') {
31
+ registerSw()
32
+ } else {
33
+ window.addEventListener('load', registerSw)
34
35
}
36
37
})
0 commit comments