Does setTimeout block the main thread in JavaScript?
No. The timer runs in a Web API outside the engine. Only the callback runs on the main thread, and only when the stack is empty. The scheduling does not block.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Blocking the Main Thread in JavaScript
Running a long synchronous function that occupies the single call stack. While it runs, the browser cannot paint, respond to clicks, or run queued callbacks. The UI freezes.
Break long tasks into chunks with setTimeout, use Web Workers for heavy computation, prefer async APIs, debounce and throttle expensive handlers, use requestAnimationFrame for visual updates, and requestIdleCallback for low-priority work.
Web Workers run JavaScript on a separate thread. Heavy computation can be sent to a worker, and the main thread stays responsive. The worker posts results back via messages.
Still have questions?
Browse all our FAQs or reach out to our support team
