Shared Workers

Shared Workers can also run computationally heavy tasks in background threads, to improve JavaScript execution time and user experience, as Dedicated Workers.

However, as opposed to Dedicated Workers, Shared Workers can be accessible from multiple scripts across the site in the same browser. That includes different tabs, windows, iframes and other workers. The worker's resources (data scope and processing power) are also shared among all accessors.

This allows communication between 2 or more main threads through a shared worker.

Your Hardware Concurrency


The following demo is a 2-player game on 2 browser windows that fully works on the client-side without any server.