[](https://travis-ci.org/GoogleChrome/sw-toolbox) [](https://david-dm.org/googlechrome/sw-toolbox) [![dev
npm install pwa-runtimebower install --save sw-toolbox
npm install --save sw-toolbox
git clone https://github.com/GoogleChrome/sw-toolbox.git
javascript
navigator.serviceWorker.register('my-service-worker.js');
`
As implemented in Chrome 40 or later, a service worker must exist at the root of the scope that you intend it to control, or higher. So if you want all of the pages under /myapp/ to be controlled by the worker, the worker script itself must be served from either / or /myapp/. The default scope is the containing path of the service worker script.
For even lower friction you can instead include the Service Worker Toolbox companion script in your HTML as shown below. Be aware that this is not customizable. If you need to do anything fancier than registering with a default scope, you'll need to use the standard registration.
`html
`
$3
In your service worker you just need to use importScripts to load Service Worker Toolbox
`javascript
importScripts('bower_components/sw-toolbox/sw-toolbox.js'); // Update path to match your own setup
``