Work in progress!
An elegant, friendly and courteous butler to avoid headaches with ServiceWorkers in a clean, elegant and simple programmatic in order to provide a better approach for insanely great use of ServiceWorker features underling ugly implementation details
ServiceWorker introduces interesting, reliable and powerful ways to do awesome things in the browsers which will evolve the Web to the next-level
Note that ServiceWorker is still an experimental technology and its standard is under active discussion and it is not currently supported by latest production browsers
Aditionally you should consider that this library is very much a work in progress, as it is a hacking-driven implementation, therefore important changes can be done in a near future and API retrocompatibility is not premise
If you are new with ServiceWorker, before getting started you could take a look to the explainer document, HTML5rocks introduction or the draft specification
Via Bower
bower install butler
Via Component
component install h2non/butler
Or loading the script remotely
<script src="//cdn.rawgit.com/h2non/butler/0.1.0/butler.js"></script>
Due to ServiceWorkers security limitations, it's required to copy the butler.worker.js
source in the root directory of your application (although, you could use the HTTP server rewrite rules to do the same in remote servers) in order to be enable the Service Worker control into the desired page scope (defaults to /
)
Example command if you are using Bower as package manager
cp ./bower_components/butler/butler.worker.js .
To start hacking with ServiceWorker you should enable the "experimental Web Platform features" flag in Canary.
You can do it opening chrome://flags
. Then you should restart the browser
Open chrome://serviceworker-internals/
, or alternatively use chrome://inspect/#service-workers
Canary ✔ | Nightly ✔ | No | ? | No |
For more information about browsers support see "is ServiceWorker ready?" site
To Do
Create a new butler instance
path argument points to the butler.worker.js
. Default to /butler.worker.js
Supported options are:
- scope
string
- Worker control path scope. Default to/
Type: string
Bock worker file path. Default to /butler.worker.js
.
Be aware with the scope
security limitation
Type: string
Current library semantic version
Wanna help? Cool! It will be appreciated :)
You must add new test cases for any new feature or refactor you do, always following the same design/code patterns that already exist
Only node.js is required for development
Clone the repository
$ git clone https://github.com/h2non/butler.git && cd butler
Install dependencies
$ npm install
Generate browser bundle source
$ make browser
Run tests
$ make test
See the examples
$ ./node_modules/.bin/http-server
MIT - Tomas Aparicio