Christian Woerz
The Eventloop in JavaScript - How does it work?
#1about 4 minutes
Differentiating between a JavaScript engine and a runtime
A JavaScript engine implements the ECMAScript standard, while a runtime adds extra functionality like Web APIs and the event loop.
#2about 2 minutes
Understanding why JavaScript needs an event loop
JavaScript's single-threaded nature can block the UI, so the event loop is necessary to handle asynchronous operations without freezing the application.
#3about 7 minutes
Exploring the core components of a JavaScript runtime
A runtime consists of a call stack for synchronous code, Web APIs for browser or Node features, and separate queues for microtasks and macrotasks.
#4about 2 minutes
How the event loop prioritizes and executes tasks
The event loop continuously checks if the call stack is empty, then processes all available microtasks before handling a single macrotask.
#5about 4 minutes
Demonstrating setTimeout and the macro task queue
Code example shows how `setTimeout` with a zero delay is placed in the macrotask queue and executed only after the synchronous call stack is clear.
#6about 2 minutes
Prioritizing promises with the micro task queue
A resolved promise is handled as a microtask, which is always executed before macrotasks like `setTimeout` when the call stack is empty.
#7about 3 minutes
How network latency affects promise execution order
Using `fetch`, this example shows that a promise is only added to the microtask queue upon resolution, so a slow network request can execute after a faster macrotask.
#8about 3 minutes
Starving the macro task queue with micro tasks
A recursive `queueMicrotask` call demonstrates how continuously adding microtasks can prevent the event loop from ever processing the macrotask queue.
#9about 2 minutes
Final recap of the event loop's execution order
The event loop prioritizes the call stack first, then the entire microtask queue, and finally a single task from the macrotask queue.
Related jobs
Jobs that call for the skills explored in this talk.
Hubert Burda Media
München, Germany
€80-95K
Intermediate
Senior
JavaScript
Node.js
+1
Matching moments
08:07 MIN
Exploring modern JavaScript performance and new CSS features
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
11:32 MIN
The industry's focus on frameworks over web fundamentals
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
07:46 MIN
The challenge of keeping up with modern CSS
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
01:32 MIN
Organizing a developer conference for 15,000 attendees
Cat Herding with Lions and Tigers - Christian Heilmann
11:10 MIN
The only frontend stack that truly matters
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
14:14 MIN
Scripting presentations and demos in VS Code
Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3
02:49 MIN
Using AI to overcome challenges in systems programming
AI in the Open and in Browsers - Tarek Ziadé
04:56 MIN
Recreating React components using AI and dev tools
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
Featured Partners
Related Videos
Catching up on the basics you don't really need that much code
Chris Heilmann
Java 21: The Revolution of Virtual Threads - A Deep Dive
Christian Woerz
Multithreading in Javascript: A guide to Web Workers
Dani Coll
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
Chris Heilmann, Daniel Cranney & Jan Deppisch
JavaScript the Grumpy Parts
Rob Richardson
Things I learned while writing high-performance JavaScript applications
Michele Riva
Node.js: More Threads Than You Think
Matteo Collina
Beats in the Browser: Coding Music with JavaScript
Rowdy Rabouw
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.

Code Healers LLC
Hinesville, United States of America
Remote
€30-40K
Intermediate
Senior
.NET
React
JavaScript
+2

Code Healers LLC
Hinesville, United States of America
Remote
€20-30K
Junior
Intermediate
React
JavaScript
TypeScript
+1

Visonum GmbH
Remote
Junior
Intermediate
React
Redux
TypeScript



MARKT-PILOT GmbH
Stuttgart, Germany
Remote
€75-90K
Senior
Java
Angular
TypeScript


United Kingdom - 2 minutes ago
Intermediate
API
GIT
Azure
React
Python
+6

Live Wire
Python
Unreal Engine