What's a Service Worker?
Web browsers evolved tremendously since the 80’s and Tim Berners-Lee’s first attempt at a software application designed to interact with web servers—now closer to full-blown virtual machines than mere applications.
We have reached a point where web browsers can seamlessly provide both rich offline and online experiences, by leveraging the same technologies used to build websites: this is why service workers are particularly interesting for modern web developers wanting to build resilient and performant web applications.
A service worker is similar to a daemon program you can find in any operating system: it’s a script running in the environment’s background, without the need of a user interaction or an open webpage. This is why you can use it without an Internet connection, even though you can interact with service workers from within a webpage using Javascript.
A service worker can be used offline, but you need to install it first by requesting it from a web server. The great thing is you don’t need to bother the user to install it, like you would with a traditional mobile app for example. Instead, the browser handles everything.
Even though you can use a service worker offline, it is restricted to the browser environment. You can’t control a computer remotely or leverage all its features. This is the cons of a service worker when you compare it to what a mobile application can do, like accessing local files from a user’s phone. It’s not very useful for most websites though.
The business applications are promising: we could theoretically replace any media file with an app using HTML, CSS, and Javascript. No need for a PDF viewer or a MP3 reader, you could just browse any document in a native web format you have total control over, without needing to stay online.