This file contains 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
.then( function( ){ | |
return self.clients.claim( ); | |
}) | |
.catch( function( e ){ | |
console.log("Error handling cache", e); | |
}) | |
); |
This file contains 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
self.addEventListener( 'activate', function( event ){ | |
event.waitUntil( | |
caches.open( 'name_your_cache_container' ) | |
.then( function( cache ) { | |
return cache.addAll( urlsToCache ); | |
}) |
This file contains 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
self.addEventListener( 'install', function(){ | |
return self.skipWaiting( ); | |
}); |
This file contains 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
return caches.open( 'name_your_cache_container' ) | |
.then( function( cache ) { | |
cache.put( event.request, resp.clone( )); | |
return resp; | |
}); | |
}); |
This file contains 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
var urlsToCache = [ 'index.html', | |
'.', | |
'img/bunny1.jpg', | |
'img/bunny2.jpg', | |
'img/bunny3.jpg' ]; |
This file contains 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
//Listen for claiming of our ServiceWorker | |
navigator.serviceWorker.addEventListener('controllerchange', function() { | |
console.log( 'Service worker status changed: ', this.controller.state ); | |
// Listen for changes in the state of our ServiceWorker | |
navigator.serviceWorker.controller.addEventListener('statechange', function() { | |
// If the ServiceWorker becomes "activated", let the user know they can go offline! | |
if (this.state === 'activated') { | |
window.location.reload( true ); | |
} | |
}); |
This file contains 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
if ( 'serviceWorker' in navigator ) { | |
navigator.serviceWorker.register('sw.js').then(function(registration) { | |
// Registration was successful | |
console.log('ServiceWorker registration successful with scope: ', registration.scope); | |
}).catch(function(err) { | |
// registration failed :( | |
console.log('ServiceWorker registration failed: ', err); | |
}); |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://pure.github.io/pure/libs/pure.js"></script> | |
</head> | |
<body> | |
<div class="testDiv"> |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://pure.github.io/pure/libs/pure.js"></script> | |
</head> | |
<body> | |
<div class="test"> |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://pure.github.io/pure/libs/pure.js"></script> | |
</head> | |
<body> | |
<div class="test"> |