Chapter 11. Web and Service Workers
Let's suppose that you are building a cool web app, say, to factorize a number to two prime numbers. Now, this involves a lot of CPU-intensive work, which will block the main UI thread. The main UI thread is the traffic lane that the end user directly observes and perceives. If it seems congested (laggy) or blocked, even for a few seconds, it destroys the user experience.
This is where web workers come into the picture. Web workers can be thought of as those side-lanes available on the road where you can divert heavy and slow (CPU-intensive) trucks so that you don't block a user's shining Lamborghini on the main road (the main UI thread).
On the other hand, service workers are quite cool, too. A service worker is your own programmable network proxy, which sits right in between the user's internet connection and your website. There will be more on that in the Working with service workers section.
In this chapter, we'll cover:
- Introduction to threads
- Introduction...