Mid JavaScript

What are web workers?

Web Workers allow JavaScript to run code in background threads, keeping the UI

responsive.

Example:

// main.js

const worker = new Worker('worker.js');

worker.postMessage('Start');

// worker.js

onmessage = e => postMessage('Task done');

More from JavaScript Tutorial

All questions for this course