Available in Chrome 39+
This sample demonstrates the most basic service worker registration scenario. The script
service-worker.js is registered to handle the URL scope
./. It is "safe"
to register the same script multiple times, it's not necessary to check for a previous registration.
The sample doesn't track the state of the registered service worker (whether it ends up being redundant, the "worker-in-waiting", etc.), but it's sufficient to ensure that a service worker will control documents under that scope the next time one of them is loaded.
service worker registration: