> Markdown version of [/videos/1673-multithreading-in-javascript-a-guide-to-web-workers](https://www.wearedevelopers.com/videos/1673-multithreading-in-javascript-a-guide-to-web-workers). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Multithreading in Javascript: A guide to Web Workers Is JavaScript actually single-threaded? Discover how Web Workers unlock true parallelism to offload heavy CPU tasks and guarantee smooth 60 FPS interfaces. - **Speakers:** [Dani Coll](https://www.wearedevelopers.com/@dani-coll) - **Event:** World Congress 2025 - **Published:** August 20, 2025 - **Duration:** 23:14 - **URL:** https://www.wearedevelopers.com/videos/1673-multithreading-in-javascript-a-guide-to-web-workers ## Summary JavaScript's single-threaded nature requires developers to master concurrency through the event loop, precisely managing the call stack alongside microtask and macrotask queues to prevent UI blocking. While synchronous code and asynchronous tricks (such as Promises taking priority over timeouts) provide concurrency, true parallelism is achieved by implementing Web Workers. As demonstrated by offloading a computationally expensive chess engine, Web Workers execute heavy processes on a separate thread, leaving the main thread entirely free to handle user interactions and render smooth 60 FPS interfaces. Despite their power, Web Workers introduce distinct limitations such as lacking direct DOM access and incurring communication overhead due to serialized data copying between threads. To navigate these constraints, developers can use the OffscreenCanvas API to seamlessly transfer graphics control inside a worker without costly serialization, or leverage libraries like Partytown to isolate non-critical third-party scripts (like analytics and chatbots) away from the main thread. Ultimately, utilizing workers for heavy data processing can drastically improve frontend metrics; however, adding them arbitrarily to a project risks decreasing performance. Engineers are advised to exhaust main-thread optimizations first, introducing multi-threaded JavaScript architectures only when dealing with severely CPU-intensive tasks or isolated external dependencies. **Keywords:** javascript event loop, microtask and macrotask queues, javascript web workers, browser multithreading, non-blocking UI rendering, inter-thread communication overhead, offscreencanvas API, partytown library, CPU-intensive frontend tasks, frontend performance optimization, DOM access limitations, neo.mjs framework, javascript concurrency vs parallelism ## Chapters 1. **Connecting frontend application performance to user retention and revenue** (00:00) — Fast frontends retain users and drive business revenue by preserving overall application performance. 1. **Processing synchronous function execution via the JavaScript call stack** (01:01) — The browser engine uses a last-in-first-out data structure to execute synchronous code natively. 1. **Prioritizing asynchronous execution using microtask and macrotask queues** (03:17) — The event loop prioritizes asynchronous callbacks by evaluating the microtask queue before the macrotask queue. 1. **Achieving true parallelism in JavaScript using web workers** (08:29) — Setting up background threads relies on message passing to execute independent scripts without blocking default processes. 1. **Offloading expensive algorithms to maintain user interface responsiveness** (11:00) — Delegating heavy decision-tree calculations to a background thread keeps the main interface smooth and interactive. 1. **Navigating web worker limitations and data serialization constraints** (16:34) — Web workers lack direct interface access and require deep copying for large data transfers between threads. 1. **Leveraging offscreen canvas to render graphics in background threads** (18:22) — Transferring canvas control directly to a worker avoids serialization overhead for complex graphical rendering. 1. **Managing external third-party scripts using the Partytown library** (19:40) — Proxying standard web functionality allows non-critical analytics tools to run entirely outside the main runtime. 1. **Calculating virtual DOM state with worker-centric frontend frameworks** (21:22) — Experimental architectures attempt to calculate all interface modifications and backend logic via dedicated workers exclusively. 1. **Weighing web worker communication overhead against baseline performance gains** (21:59) — Optimizing existing single-threaded logic is essential before accepting the architectural complexity of cross-thread messaging. ## Related Moments - [Offloading WebAssembly execution to background web workers](https://www.wearedevelopers.com/videos/1985-speeding-up-web-apps-performance-with-webassembly-and-emscripten) (from "Speeding up Web Apps performance with WebAssembly and Emscripten") - [Why single-threaded JavaScript needs an event loop](https://www.wearedevelopers.com/videos/1211-the-eventloop-in-javascript-how-does-it-work) (from "The Eventloop in JavaScript - How does it work?") - [Offloading tracking tasks from the main thread to web workers](https://www.wearedevelopers.com/videos/285-the-lean-web) (from "The Lean Web") - [Understanding service worker threads and event-driven architecture](https://www.wearedevelopers.com/videos/645-offline-first) (from "Offline first!") - [Transitioning native desktop graphics implementations to the web](https://www.wearedevelopers.com/videos/1794-wearedevelopers-live-from-javascript-to-webassembly-high-performance-charting-and-more) (from "WeAreDevelopers LIVE – From JavaScript to WebAssembly, High-Performance Charting and More") - [Managing the single-threaded Node.js event loop](https://www.wearedevelopers.com/videos/306-javascript-the-grumpy-parts) (from "JavaScript the Grumpy Parts") ## Related Articles - [Dev Digest 136 - No JS(on) of mine](https://www.wearedevelopers.com/magazine/482-dev-digest-136-no-js-on-of-mine) - [Dev Digest 106 - DHH in HD](https://www.wearedevelopers.com/magazine/394-dev-digest-106-dhh-in-hd) - [The Concept of Concurrency & Multithreading: What Are They And How They Function](https://www.wearedevelopers.com/magazine/89-the-concept-of-concurrency-multithreading-what-are-they-and-how-they-function) - [Dev Digest 108 - Git off my cloud!](https://www.wearedevelopers.com/magazine/407-dev-digest-108-git-off-my-cloud) ## Related Jobs - [Staff Frontend Engineer](https://www.wearedevelopers.com/jobs/48313-staff-frontend-engineer) at **SMG Swiss Marketplace Group** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/679408-remote-senior-full-stack-engineer) at **Edge Impulse** - [Junior Frontend Engineer](https://www.wearedevelopers.com/jobs/ext/1532351-junior-frontend-engineer) at **Almedia** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/645320-remote-senior-full-stack-engineer) at **Edge Impulse** - [Staff Frontend Engineer (Expert+/Lead equivalent) - Hybrid working model, 100%, Ho Chi Minh City](https://www.wearedevelopers.com/jobs/48314-staff-frontend-engineer-expert-lead-equivalent-hybrid-working-model-100-ho-chi-minh-city) at **SMG Swiss Marketplace Group** - [Remote Senior Full-Stack Engineer](https://www.wearedevelopers.com/jobs/ext/682327-remote-senior-full-stack-engineer) at **Edge Impulse**