Course contentsShow
← JavaScript
Lesson 2156 of 2,72345. Workers and ConcurrencyFree lesson

Web Worker Limitations

Explore what APIs are unavailable in workers: no DOM access, no window object, and restricted synchronous operations.

Web Worker Limitations

You'll learn what you cannot do inside a Web Worker—understanding these boundaries is essential for effective worker design.

Why Workers Have Restrictions

Web Workers run in a completely separate thread, isolated from your main page. This isolation is powerful for concurrency, but it means workers don't have access to many APIs that rely on the page's environment. Think of a worker like a backstage crew member: they can do heavy lifting behind the scenes, but they can't directly interact with the audience (your UI).

What's Off-Limits

No DOM Access

Workers cannot access document, manipulate elements, or use any DOM APIs. You can't call querySelector, change styles, or update innerHTML—those operations must happen on the main thread.

No Window Object

The global scope in a worker is self, not window. APIs tied to window are unavailable: no alert(), confirm(), localStorage, or sessionStorage. You also can't access window.location directly.

Restricted Synchronous Operations

Workers avoid blocking operations. You can't use synchronous XHR (though async fetch works fine). File system access, if available, must be asynchronous.

No Parent Scope Access

Workers can't reach variables or functions defined in your main script unless you explicitly send them via postMessage. They're completely sandboxed.

What Is Available

Workers still get fetch, setTimeout, setInterval, console, importScripts, and most computation-focused JavaScript features. They're perfect for calculations, data processing, and network requests—just not UI work.

Key Takeaway: Web Workers cannot touch the DOM, access window, or use synchronous APIs—they're isolated compute environments that communicate only through messaging, making them ideal for background tasks but unsuitable for direct UI manipulation.