DELAPARRA
Index
Color
NL
Category: Programming paradigms

Event Loop

Explained by Updated

What is Event Loop?

Event Loop: JavaScript's mechanism for handling async events on a single thread. It continuously checks the event queue and runs callbacks when the main thread is free. The event loop is how JavaScript handles many tasks on a single thread. It runs one piece of code at a time. When that piece finishes, the loop takes the next waiting callback from the queue and runs it.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Event Loop

How is Event Loop used in practice?

Slow operations, such as network requests and timers, are handed off to the browser or Node.js. When they finish, their callback joins the queue. That is why a page stays responsive while data loads.

What should you keep in mind with Event Loop?

The catch is that long synchronous code blocks everything. A loop that takes two seconds freezes the whole page, including clicks and animations, because the event loop cannot move on. Split heavy work into smaller pieces, move it to a Web Worker, or do it on the server. In Node.js, the same rule protects a server from becoming unresponsive for every user.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with E

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.