The Event Loop Tick Cycle
You'll learn how the event loop processes one complete iteration—from executing a task to draining microtasks to updating the display.
Now that you know JavaScript has two queues (tasks and microtasks) and that microtasks run before tasks, let's see how the event loop combines everything into one repeating cycle called a "tick."
What Happens in One Tick
Think of a tick like one revolution of a wheel. The event loop continuously spins through these steps:
- Run one task from the task queue (if any are waiting)
- Drain all microtasks — run every microtask in the microtask queue until it's empty
- Render — update the screen if needed (browser decides when)
Then the cycle repeats. Over and over. Forever.
Why This Order Matters
The event loop doesn't pick randomly. It follows this exact sequence every time. After completing one task (like a setTimeout callback), it must check and empty the entire microtask queue before moving to the next task or rendering.
This is why Promise .then() handlers (microtasks) always run before the next setTimeout (task), even if the timeout delay is zero.
The Rendering Step
The browser doesn't render after every tick—that would be wasteful. It typically aims for 60 frames per second (one frame every ~16ms). The event loop gives the browser a chance to render after draining microtasks, but the browser may skip rendering if nothing changed or if it's not time yet.
Key Takeaway: One event loop tick = run one task → drain all microtasks → render (if needed). Understanding this cycle explains how JavaScript manages synchronous code, promises, timers, and screen updates in a single-threaded environment.