Javascript: Service Worker Downsides

by Mark Zinzow
From the Status Register of the Champaign-Urbana Computer Users Group
December 2019

One of my interests with JavaScript is how knowing just a little can empower end-users. (E.g. useful one liner bookmarklets.) It was one of the JavaScript Meetup talks that informed me that service workers even exist, and what their use is. However, as an end user, I've noticed several downsides of them in Chrome.

Today I opened the Chrome browser, and noticed once again I got a desktop notification ad from a vitamin company I ordered something from once. This ad was starting to pop up every time I opened my browser despite running an ad blocker. Not only that, I consider desktop notification ads to be even more annoying. So I went into the developer tools, and unregistered that service worker, and a bunch of others from sites I almost never visit, and don't want offline content from. I used Process Hacker to note that Chrome memory usage dropped from about 2.5Gb to 1.1Gb, and with each service worker I deleted, one Chrome process thread went away. Some sites like AliExpress had a service worker for each store I'd visited in that site! After restarting the browser, that annoying ad was gone! (I also blocked JavaScript on that vitamin site, as there seems to be no other way to block a service worker in Chrome.)

Service Workers in Firefox and Chrome

Firefox gives the end user more control over service workers.

I conclude these are getting to be like spyware, causing browser bloat leading to system bloat. Since closing a tab to a site does not stop the service worker thread, all service workers ever loaded are loaded every time you start the browser! Imagine if a hundred websites installed service workers. It might be worse than trying to load 100 tabs every time you start the browser. It reminds me of all the processes that slow down system startups so that every program you install can have its own updater.

I think sites should ask for end user approval to install a service worker, and explain the pros and cons. If a site is rarely used, the cache may not actually be of value to the end user, and as more and more sites use them browser bloat could get to be a bigger problem. (My system with 16Gb of ram has been warning me to close programs as I'm running out. Now I know one reason why! I'll have to see if this helps my Chromebook as well!) I imagine some less respectable sites could even install multiple cyrptocurrency miners further bogging down popular browsers. Even worse, sites could hijack your bandwidth for a geoblocker, spam engine, botnet or vpn. The malware implications are scary! End user impact could be far worse than cookie abuse!

Master of Web Puppets

I don't really know enough about this to do a real presentation, but I think this would be an interesting discussion topic for our group. I'd be willing to tell the story I've basically outlined here, and would be interested in expert opinions. Does anyone know if one could add service worker blocking to an ad blocker? (Google didn't seem to find that answer for me.)