4 Creative Service Worker Use Cases

↑ ………. Worker ↑

Service worker, a new member of javascript workers family, is getting more and more attention thanks to the popularization of Progressive Web Applications. Usually people use it to cache their websites assets, but sometimes, they come up with really interesting ways to utilize this technology. I wanted to share with you, a few of them that really caught my eye.

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!

https://github.com/bahmutov/bottle-service

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!

https://serviceworke.rs/cache-from-zip_worker_doc.html

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.

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.

https://serviceworke.rs/load-balancer_service-worker_doc.html

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!

About us

Applantic is a team of passionated software developers. We write our stories on Medium ✍ but you can find us on Instagram 📷 or Facebook ✍ as well.

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.