4 Creative Service Worker Use Cases
1. Service Worker Prerender
Don’t you hate the flash of content, when your web application re-renders on page reload? Well, worry no more! Gleb Bahmutov came up with a great idea, to write a service worker utility, called bottle-service that allows you to snapshot your page’s rendered HTML structure, and cache. It removes the flash of content, when your web application gets hydrated with real data. For more information you can check out authors blog post. It’s really neat!
2. Sending your website through a single ZIP
The title is quite self-explanatory. This implementation, presented on serviceworke.rs website, allows to distribute a website through a ZIP package. I’m not sure if it’s a ‘real-world’ situation, but without doubt, it’s a really creative use case!
3. Offline Analytics
In the past, when websites were only an on-line experience, you didn’t need to know what your users did on your website when they were offline. Nowadays, when Progressive Web Apps are slowly becoming a reality, and your customers actually can use the site offline, it’s important to be able to still get all the information about the app usage, through analytics. Google came up with a solution. Their service worker plugin works only for google-analytics, but it shows the possibility of offline user tracking.
The sw-offline-google-analytics library gives you everything you need.developers.google.com
4. Load Balancer
This one also comes from serviceworke.rs website. You can find a lot more interesting stuff there, so I recommend you check it out. This implementation shows, how to use service worker to dynamically choose the best content provider according to server availability.
Spread The Word
I hope the above examples will convince you to read more about service worker, and spread the word, so that people finally update their old browsers and everybody can benefit from the service worker magic!
Tap the 👏 button if you found this article useful!
The author of this article is Maciej. Front-end developer, working on web applications in a software house. He is interested in many things, even some that are not related to computer science, such as sports and music. You can find him on GitHub or LinkedIn.