Skip to content

Instantly share code, notes, and snippets.

@KaySchneider
Created March 30, 2017 19:16
Show Gist options
  • Save KaySchneider/7caa769eb4b62cb2208bd95aabadd728 to your computer and use it in GitHub Desktop.
Save KaySchneider/7caa769eb4b62cb2208bd95aabadd728 to your computer and use it in GitHub Desktop.
Simple demo, how to register an service worker. The registration process can be also done inside an javascript file.
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Hello, world</h1>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('./serviceWorker.js')
.then(function() { });
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment