Event loop and asynchrony in JavaScript
summary
Explains why JavaScript remains single‑threaded while performing asynchronous work and describes the event loop implementation: setTimeout callbacks go to a FIFO task queue, requestAnimationFrame uses a render queue processed before painting, and Promises/MutationObserver schedule higher‑priority microtasks that run to exhaustion. Demonstrates with live examples (100 timeouts and a click handler, then hundreds of thousands of Promise microtasks) to show how microtasks can block rendering, and mentions Internet Explorer differences and requestIdleCallback as an alternative.
AI-written summary · about








