Skip to content

Instantly share code, notes, and snippets.

@leon0707
Last active February 4, 2020 14:59
Show Gist options
  • Save leon0707/c6b450932c970888e217b581bfe091f2 to your computer and use it in GitHub Desktop.
Save leon0707/c6b450932c970888e217b581bfe091f2 to your computer and use it in GitHub Desktop.
client
// 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