Below is some boilerplate for using service workers inside a project so that a web application can still run to some degree in an offline environment
register-service-worker.js
would be loaded into your normal javascriptservice-worker.js
would be on it's own in the directory you wish to run the service worker inside (urls should reflect this)- Things in
<>
brackets will need to be replaced by their relevant information
Note: Service Workers can only be run in an SSL secured environment
Note: Service Workers have a poor support at the moment, but may have greater support in the future
Here's the demo that can be used offline https://alberon.gitlab.io/service-workers-demo/
Date: 8th January 2018