Last active
February 4, 2020 14:59
-
-
Save leon0707/c6b450932c970888e217b581bfe091f2 to your computer and use it in GitHub Desktop.
client
This file contains hidden or 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
| // client.js | |
| if ('serviceWorker' in navigator) { | |
| // register a service worker for this site | |
| navigator.serviceWorker.register('cache-worker.js'); | |
| navigator.serviceWorker.ready | |
| .then((reg) => { | |
| // registration worked | |
| console.log('Registration succeeded. Scope is ' + reg.scope); | |
| }).catch((error) => { | |
| // registration failed | |
| console.log('Registration failed with ' + error); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment