Which Web API offloads expensive work from the main UI thread?

WHAT IT TESTS: knowledge of moving CPU-heavy work off the main thread. ANSWER OUTLINE: cite Web Workers, instantiate new Worker(url), and communicate via postMessage and onmessage. RED FLAG: citing setTimeout or async/await, which still run on the main thread.
WHAT IT TESTS: whether you understand that JavaScript's single-threaded nature blocks the UI during heavy computation and requires a true background thread to keep the interface responsive. ANSWER OUTLINE: identify the Web Workers API, explain that new Worker(scriptUrl) spawns a separate thread, and describe the postMessage and onmessage pattern for sending the JSON payload and receiving results back. RED FLAG: recommending setTimeout, requestIdleCallback, or async/await, which remain on the main thread and do not prevent UI freezing.
Read the original → developer.mozilla.org
- #web workers
- #javascript
- #browser apis
- #concurrency
- #ui threading
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.