diff options
author | Alexander Kiryukhin <a.kiryukhin@vk.team> | 2023-02-16 15:18:56 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@vk.team> | 2023-02-16 15:18:56 +0300 |
commit | a9a4527af2be6163bb41342e1eb22e93c59b38b4 (patch) | |
tree | 8aaaf3e04d1dad144eba193d8495fb1c2fe30c10 | |
parent | 0984eb2a835eb2234bdc61e67039b9e741a0d934 (diff) |
-rw-r--r-- | index.html | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -22,10 +22,25 @@ <link rel="stylesheet" href="css/styles.css?v=1.0"> <meta name="theme-color" content="#4285f4" /> <link rel="manifest" href="/manifest.webmanifest"> + </head> <body> <h1>WebApp example</h1> - <script src="js/scripts.js"></script> + <script> + // Don't register the service worker + // until the page has fully loaded + window.addEventListener('load', () => { + // Is service worker available? + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/service-worker.js').then(() => { + console.log('Service worker registered!'); + }).catch((error) => { + console.warn('Error registering service worker:'); + console.warn(error); + }); + } + }); + </script> </body> </html> |