midHTML5
What are Web Workers?
Updated Apr 28, 2026
Short answer
A script that runs in the background, independent of the main UI thread.
Deep explanation
They allow for heavy computation without freezing the user interface. Workers communicate with the main script via messages and do not have access to the DOM.
Real-world example
Processing a large CSV file in the background while the user continues to use the app.
Common mistakes
- Trying to access the 'window' or 'document' object inside a worker.
Follow-up questions
- Do Web Workers make JS multi-threaded?