Event loop
How JavaScript runs one task at a time and queues the rest: callbacks, promises (microtasks), timers and rendering.
JavaScript in a page has one main thread. The event loop takes a task, runs it to the end, drains the microtask queue (resolved promises), and lets the browser render before the next task. A long task blocks clicks and painting, which is what users feel as a frozen page and what INP measures. Node.js has its own event loop with the same idea.
Related terms
- Request waterfall: Requests that wait for each other in sequence when they could run in parallel, so load time adds up.
- Core Web Vitals (LCP, INP, CLS): Google’s three metrics of real user experience: loading (LCP), responsiveness (INP) and visual stability (CLS).
- Server-Sent Events (SSE): A standard way for a server to push a stream of updates to the browser over one long HTTP response.
