Slide 17
Slide 17 text
Copyright ⓒ All Right Reserved by Buzzvil
Service Worker Register
Register Install Waiting Activate
serviceWorkerContainer.register(scriptURL, options)
.then(function(serviceWorkerRegistration) { ... });
• If successful, a service worker registration ties the provided scriptURL to a scope url,
which is subsequently used for navigation matching.
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', {scope: './foo/bar/'})
.then(function(registration) {
console.log('Service worker registration succeeded:', registration);
});
}