Skip to content

Instantly share code, notes, and snippets.

@erdoganoksuz
Created March 26, 2018 16:47
Show Gist options
  • Save erdoganoksuz/cc0174153c95a418142bb636c3c27d72 to your computer and use it in GitHub Desktop.
Save erdoganoksuz/cc0174153c95a418142bb636c3c27d72 to your computer and use it in GitHub Desktop.
Service Worker Network Test
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1 id="text">Heyy</h1>
<button onclick="getData()">GetData</button>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js').then((registration) => {
return navigator.serviceWorker.ready;
}).catch(function (error) {
console.log('Unable to register Service Worker.');
});
} else {
console.log('Service Worker functionality not supported.');
}
function getData() {
fetch("https://jsonplaceholder.typicode.com/posts/1")
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment