Workers are brilliant.

A single worker can give the main thread some much needed breathing room, extending an application’s processing capacity. The application’s UI hums along whether you’re processing video, auto-tuning some audio, or generating a dank meme.

But if workers are so great, why are they so under utilized? Are UI performance issues not common? That can’t be the case in a world full of JavaScript on mobile devices. So what gives? Well, I have a theory.

Web Workers aren’t under utilized not because we don’t need them. Web Workers are under utilized because they’re frustrating to manage.

The problem with Workers? Communication.

The other week I wrote an article on using Web Workers in a Firebase app. The results were incredible. Using a web worker took 95% of my JavaScript code out of the critical path while retaining the same functionality. Offloading the work improved page load and processing, but the development experience was difficult.

The premise of Web Workers is offloading some code to another thread. This power comes with responsibility. You now have to communicate between the main thread and the worker thread. How do you communicate with a worker? Messages.