Check out a free preview of the full Progressive Web Applications and Offline course:
The "Dedicated vs. Shared Workers" Lesson is part of the full, Progressive Web Applications and Offline course featured in this preview video. Here's what you'd learn in this lesson:

Mike illustrates the differences between dedicated and shared workers.

Get Unlimited Access Now

Transcript from the "Dedicated vs. Shared Workers" Lesson

>> Mike North: When talking about dedicated workers and shared workers, so dedicated workers are by far the most common. And when a script creates a worker using that worker constructor, let's say it's our app.js, inside there, we're creating this worker. Only that frame in which that script is running can talk to that worker.

[00:00:22] So if you were to have an iframe, and even if it's in the same origin, it's not going to be able to connect to that worker. So whatever, the creator can talk to it, it can talk back to the creator, and that's it. For our purposes, the exercise we're going to work on is we're going to take something that is computationally very intensive.

[00:00:42] And move it so that it's done in parallel, off of our main thread, this will suit our needs just fine. Shared workers allow inter-frame communication to happen, right? So you could have one worker running, and three iframes, two browser tabs, and another window are all connecting to this thing.

[00:01:04] You'll basically open up sockets and can allow multiple things to connect to it. While this is interesting, usually it is not the tool that you need, in terms of just taking advantage of pure parallelism. So just know that it exists, know that if you want to build some app that has five iframes talking to each other.

[00:01:29] This is probably something that you should research, but that is not really taking us further down the progressive web app road.