Skip to content

Instantly share code, notes, and snippets.

@devNigel
Last active March 31, 2018 19:25
Show Gist options
  • Select an option

  • Save devNigel/c55ec416a1761cd5fe85de3fff7dc8bd to your computer and use it in GitHub Desktop.

Select an option

Save devNigel/c55ec416a1761cd5fe85de3fff7dc8bd to your computer and use it in GitHub Desktop.
Beginner’s Guide to Converting a Javascript App to a Progressive Web App (PWA)
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
/*
game logic
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment