WeAreDevelopers LIVE Sep 18, 2024

The Eventloop in JavaScript - How does it work?

Christian Woerz

Why do recursive promises sometimes freeze your JavaScript application? The culprit is often microtask starvation. Master the event loop to debug complex race conditions and write non-blocking code.

Pause
Mute Enter Fullscreen
#1 about 7 min

Differences between JavaScript engines and runtimes

How engines implement the ECMAScript standard while runtimes provide additional APIs like timers and network requests.

#2 about 3 min

Why single-threaded JavaScript needs an event loop

Offloading execution to asynchronous tasks prevents slow, synchronous operations from blocking the single-threaded user interface.

#3 about 1 min

Understanding the role of the call stack

The call stack sequentially tracks and executes all currently running synchronous code.

#4 about 2 min

How the macro task queue handles callbacks

Runtimes utilize a first-in-first-out queue to store and execute completed callbacks from web APIs.

#5 about 2 min

Prioritizing promises with the microtask queue

Resolved promises and async operations enter a high-priority queue that precedes standard callback execution.

#6 about 3 min

Orchestrating asynchronous timers with runtime APIs

External runtime APIs process asynchronous operations before pushing callback results into the appropriate task queues.

#7 about 3 min

Event loop orchestration and execution priority

The loop continually checks the call stack before pulling prioritized tasks from the micro and macro queues.

#8 about 4 min

Visualizing JavaScript execution order with live code

Live coding demonstrates how synchronous code evaluates before asynchronous timer callbacks can enter the macro queue.

#9 about 2 min

Evaluating microtask priority over macro tasks

Immediately resolved promises bypass timer callbacks due to the strict priority given to the microtask queue.

#10 about 3 min

Handling long-running asynchronous HTTP network requests

Network requests delay entry into the task queue until completion, fundamentally altering the expected execution order.

#11 about 5 min

Starving the macro task queue with continuous microtasks

Recursively generating new microtasks blocks the event loop from ever reaching underlying macro task callbacks.

Matching moments

2:29 min

Visualizing the browser event loop execution architecture

Rob Richardson · JS Congress

1:26 min

Managing the single-threaded Node.js event loop

Rob Richardson · JS Congress

3:54 min

Asynchronous programming syntax and event loop execution

Fabian Schindler · LIVE

2:15 min

Processing synchronous function execution via the JavaScript call stack

Dani Coll Dani Coll · WWC 2025

8:07 min

Modern JavaScript loop optimization and CSS innovations

Chris Heilmann +2 · LIVE

5:12 min

Prioritizing asynchronous execution using microtask and macrotask queues

Dani Coll Dani Coll · WWC 2025

Upcoming sessions on this topic

Open session

World Congress 2026 North America

Loop Engineering in the Wild: A Live Multi-Agent Coding Session

Vlad Luzin

CTO and Cofounder at BAND

Vlad Luzin
Open session

World Congress 2026 North America

The Agentic Engineering Loop

Kevin Lin

Member of Technical Staff at OpenAI

Kevin Lin
Open session

World Congress 2026 North America

How to generate business value through performance optimizations

Nikolai Sidiropulo

Software Engineer at Meta

Nikolai Sidiropulo
Open session

World Congress 2026 North America

Full Stack with Flutter - are we there yet?

Nemanja Stošić

Senior Flutter Developer

Nemanja Stošić
Open session

World Congress 2026 North America

The $0.15/month Algo-Trader: Architecting High-Performance Serverless Trading Engines

Vishwak Thatikonda

Lead Full Stack Engineer at SDH Systems

Vishwak Thatikonda
Open session

World Congress 2026 North America

Fast by Design: A Masterclass in High-Performance Web Engineering

Aaron Grogg

Senior web developer, committed to improving the user experience by improving web performance

Aaron Grogg