WEB WORKER
A Web Worker lets JavaScript run in the background, on another thread, so your main UI thread can keep doing its job.
Why they exist
JavaScript in the browser is single-threaded.
So when you do heavy work:-The page dies. Gracefully.
Web Workers fix this by moving heavy work off the main thread.
Can Do
Heavy calculations
Encryption / decryption
Video processing
Anything CPU-intensive
❌ Cannot do
Access DOM
Touch window, document, alert
Directly modify UI
Data is copied or transferred, not shared (unless using SharedArrayBuffer)
Types of Web Workers
1.Dedicated Worker
One page → one worker (most common)
2. Shared Worker
Multiple tabs → one worker
Rare. Slightly cursed.
3. Service Worker
Offline, caching, push notifications
Real-world usage
Video players (HLS, DASH)
Crypto / hashing
Image processing
Large JSON parsing
CAPTCHA behavior analysis
Analytics that should not freeze UI






