DEV Community

Cover image for ✨♻️ JavaScript Visualized: Event Loop

✨♻️ JavaScript Visualized: Event Loop

Lydia Hallie on November 20, 2019

If you're here in 2024 (or later), here's an updated blog post!](https://lydiahallie.com/blog/event-loop) Oh boi the event loop. It’s one o...
Collapse
 
logan70 profile image
Logan

Hi, Lydia Hallie, it is a great article.

Can I translate this article into Chinese to help more Chinese developers(With original author and link, of course).

Collapse
 
lydiahallie profile image
Lydia Hallie

Absolutely!

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
diegolepore profile image
Diego Palacios Lepore

Hi, Lydia!

This is such a great article! 😃

I was looking a clear post about this subject and yours is super comprehensive and well explained (btw, I loved the gifs). I'm planning to talk to my team about the event loop soon (in spanish).

I'm sure you might have heard about this tool that helps you play with this cycle and see in real time how it goes:

latentflip.com/loupe

Collapse
 
q118 profile image
Shelby Anne

woah that tool is awesome!

Collapse
 
ayaz profile image
Muhammad Ayaz

The tool is amazing, if we have 2 aysnc functions, the web api section will only show the latest one

Collapse
 
sherlockliu profile image
Sherlock

Amazing tooling!!!

Collapse
 
miodragdz profile image
Miodrag Dzamic

I tried to copy paste some code into tool and it does not save after clicking Save+Run button. Does someone else has same issue? Thanks!

Collapse
 
karataev profile image
Eugene Karataev

Thanks for the great article and animations!
It's interesting why "event loop" question is so common on interviews, if it's job is just to transport code blocks from the queue to the call stack. I think better question would be to ask to describe how the JS mechanism works as a whole thing with call stack, web api, queue and event loop.

Collapse
 
rafaelbeckel profile image
Rafael Beckel

Interesting article! What did you use to animate the gifs?

Collapse
 
lydiahallie profile image
Lydia Hallie

As a true professional I use keynote and screen record it lol

Collapse
 
squidbe profile image
squidbe

Professional enough!

Collapse
 
thebilson profile image
thebilson

I'm also a visual learner, so this was very helpful. I'm still early on with JavaScript and it's challenging to understand it all; are there any books out there for us visual learner that you might recommend?

Collapse
 
toanoop profile image
Anoop Sivadas

Try the book written by a John duckett

Collapse
 
ocalde profile image
Oscar Calderon

Hi Lydia. Thanks for taking the time of generating these animations in order to explain it in a very simple way. Still, I have doubts regarding the Call Stack. Is it the same as the main thread in which JS runs? I mean, I understood that, although JS is single threaded, but for the asynchronous logic that gets executed, NodeJS would spawn threads for it while processing the main logic in the single thread. Thanks in advance :)

Collapse
 
codefinity profile image
Manav Misra

This is a great ❓, but probably gets a bit more 'low-level' than we need to just understand the behavior of our JS code with relation to the event loop.
However, my understanding is that the JS Engine/Runtime Environment consists of only the stack and the heap. The stack is what is 🏃🏽‍♂️on that single thread. Meanwhile, that message queue is part of the asynchronous browser environment. So, JS's single thread runs through call stack on its single thread and then checks that mesage queue to see what else needs to be done on its thread when it has the chance.

Collapse
 
avneeshroks profile image
avneeshroks

I think in case of NodeJs, it's just the c++ Api's Insted of web/browser's Api.

Collapse
 
sebasqui profile image
SebasQuiroga

Hi @avneeshroks , I have recently cloned and run the NodeJS code and effectively C/C++ are dominant.
Remember that NodeJS is on top of the V8 engine (the one used in the Chrome browser) that Google opensourced and it is natively written in C++, running in the browser and running in a server are two different environments with different purposes and indeed different APIs. NodeJS is literally running on the same engine than Chrome, but for NodeJS it is not needed to have APIs such as those for the DOM, Window, etc as Chrome needs.

Collapse
 
rjmunhoz profile image
Rogério Munhoz (Roz)

Awesome article! This has helped me a lot!

I was thinking about translating this series into Brazillian Portuguese. Do you happen to know if anyone has done it yet? Would you mind me doing it (ofc with links to the original series)

Collapse
 
codajoao profile image
João Paulo

I had the same ideia. I really want to share with the team i'm part of so did you translate it or not? You found someone that did the translation of this article?

Collapse
 
tryjude profile image
Jude

I'm not a JS developer but every now and then I have to dig into it. Over the past few years I've read lots of random things about the event loop but this is the first time I've had a clear picture of what's going on in the web browser (via the web api). Thanks!

Collapse
 
rodrigues profile image
Leandro Rodrigues

Great article Lydia.
Thanks so much for bring that clear explanation.

Collapse
 
stanleysathler profile image
Stanley Sathler

Thank you so much for the illustrations, Lydia! Very helpful, indeed!

One question: what happens when the main thread is blocked - i.e. the UI freezes? Would the whole interaction within that viewport be blocked - e.g. cursor wouldn't change after hovering a link?

I think I've never faced this situation before, so I'm curious how to identify such situation. Is there any way to simulate a huge processing in order to freeze my UI, just to see that?

Thanks in advance!

Collapse
 
brunouyuy profile image
bru

Hi, you can try this:

        function wait5seconds() {
            const plus5seconds = new Date().getTime() + 5000;
            while ( plus5seconds > new Date().getTime() ) {}

            console.log( 'wait5seconds end' );
        }


        function clickHandler() {
            console.log( 'click event' );
        }

        document.addEventListener( 'click',
            clickHandler ); // al comunicarme con la API del DOM estoy saliendo de JS 

        wait5seconds();
        console.log( 'end script execution' );
Enter fullscreen mode Exit fullscreen mode

Execute this script, and press a lot of clicks, the clicks events will appear at the end ( because the dom events are push into the queue.

I think that what you need to take into consideration is when you are performing a task that it might take some time, that might block the UI.

Collapse
 
gaurangdhorda profile image
GaurangDhorda

In this particular case de-bouncing is useful when we click on button..

Collapse
 
cryptic022 profile image
Pankaj Kumar

Just write a for loop which is printing millions numbers. Call this function on any click function. You will see the effect.

Collapse
 
ccwukong profile image
Nick Chen

Hi Lydia, I love the series. Just wondering what tool did you use to make those animations? I'm also writing some tech stuff but I can't find a perfect virtualization tool to illustrate my ideas, but your animations really match what I was looking for.

Collapse
 
karim_muhammad profile image
Karim Muhammad • Edited

I have question here...

function hello() { // sync
console.log("hello");
}
function afterWhile() { async
  setTimeout(()=> {
    console.log("After Timer")
  }, 0)
}
afterWhile();

hello();  // gets added in callstack then pop it out sequentally;
// so callstack is empty here, i guess?!!!! so why callback hasn't been executed here, in this time

hello();
Enter fullscreen mode Exit fullscreen mode

callstack here carry on one task then remove it, so why callback hasn't executed after popping out instanctly?

Collapse
 
jeannotmn profile image
Jeannot MN

Functions are pushed into the the call stack when the callstack is empty AND there are no other line of code to be executed in the main thread... in your case it was not pushed because there was still one more thing to execute in the main thread of execution (the second hello()); Only after completing the second call to the hello function that your callback will be pushed into the callstack...

I hope this helps.

Collapse
 
miwsyed profile image
Syed Mustafa Naqvi

Hi, Lydia Hallie can you tell me what is the case with setInterval in call stack a combination of setTimeout and setInterval see the usecase below. Is setInterval also supposed to go to webAPI?



let c = 0;
let id = setInterval(()=> {
console.log(c++)
},200)

setTimeout(()=> {
clearInterval(id)
},2000)
// prints
/* 0
1
2
3
4
5
6
7
8 
9
and then stops  */
Enter fullscreen mode Exit fullscreen mode
Collapse
 
1option profile image
Maksim Rozhkov • Edited

2000/200 = 10 times

after 2 seconds we clear setInterval id

Collapse
 
jonasroessum profile image
Jonas Røssum

Really nice article!
One thing I was confused about was

invoke bar. bar returns a setTimeout function.
Enter fullscreen mode Exit fullscreen mode

Doesn't setTimeout return an id that you can pass to clearTimeout? 🤔

Collapse
 
sirjoe profile image
Ibrahim Joseph

Yes, It does Jonas, so lets say


let id = setTimeout( () => {
return "hey"}, 1000);

console.log(id) // you will get 1

let id2 = setTimeout( () => {
return "hey"}, 1000);

console.log(id2) // you will get 2

Collapse
 
thamerbelfkihthamer profile image
thamer belfkih

thank guys to point out this detail, in the same context what's the purpose of this Id and it is used by the web API or the call stack for some purpose? thanks in advance

Collapse
 
rishavkumar11111 profile image
Rishav Kumar

Hi, Lydia Hallie, this is a really informative article.
Please make a similar article on event loop in Node.js if possible.
It will be of immense importance to me as I am unable to get a proper explanation with an example.

Collapse
 
olesbolotniuk profile image
oles-bolotniuk

The best explanation I've ever seen, thank you for sharing!
What's the role of the HEAP that's mentioned on the first picture?

Collapse
 
ruizhen88 profile image
Yejin

Thanks for the great article, Lydia! Do you mind if I translate this JS Visualizeed series into Korean with the original article and author credit? I think a lot of Korean developers would be interested in learning them.

Collapse
 
omarpervez profile image
Omar Pervez

It's great article I saw. I have no more confused about it. I was trying to learn it but I can't. but Thank God, That I got your article on my browser home page. I want to also thank you daily.dev. they saw your article on my home page and I have come to your article and learned about event loop. Again Thank you so much Lydia Hallie from Omar.

Collapse
 
maedehjavadi profile image
maedehjavadi

This is the greatest article about Event Loop I've ever seen. You provided a complete explanation in a short time—perfect!
I hope you keep providing these videos, they are useful for every web developer.

Collapse
 
chanmilee profile image
Chanmi Lee

Tons of thanks for this great article and awesome animations! :)
I wonder if it would be possible to translate this article to Korean with the original post link for making this useful content be more accessible for other readers.

Collapse
 
max_tulian profile image
Max (he/his)

Good post, I really appreciate the effort you do to explain the things :)

Collapse
 
kallekall profile image
Johannes

Hi Lydia,

I'm refreshing my knowledge on the event loop and even though your article is mostly correct, it does not start strong with the incorrect statement:

The respond function returns a setTimeout function.

This is incorrect. The respond will return an integer. You can easily check this yourself by doing:

const returned = respond();
console.log(returned === parseInt(returned)) // true
Enter fullscreen mode Exit fullscreen mode
Collapse
 
adnanbabakan profile image
Adnan Babakan (he/him)

Hi Lydia
This an amazing visualization and demonstration of JavaScript event loop.

I want to ask you permission to translate this article to Persian (Iran's language) with the original post link of course so this article would be more accessible for other readers.

Collapse
 
lydiahallie profile image
Lydia Hallie

Sure 😃

Collapse
 
aaktansel profile image
aaktansel

Hi Lydia ,

Thanks for this useful article explaning a difficult to understand concept in a very simple way. And i want to translate it to Turkish to share in my personal blog, with linking the original author, do you have permission for this?

Collapse
 
escornwell profile image
Eric Cornwell

Great explanations and descriptions. Interesting to note that in the final example the timer value is unimportant. Someone who is unaware of how the queue works might be surprised to find that a timer value of 0 still logs "Second" last. Which is actually an easy way to yield to the UI during a long-running process if it can be continued via a timer callback, which will happen virtually immediately if the queue is empty.

Collapse
 
ramiroogh profile image
Ramiro

excelente articulo, pensar que hace unos meses no entendia nada pero guarde el articulo ya que sabia que esto era clave, y ahora de tanto repasar js vanilla, pude entender jeje saludos desde la Patagonia, argentina.

Collapse
 
banzy profile image
Vicent

Bravo! It's a great article, exactly what I was looking for showing to my team.
Just an extra consideration, it would be very cool to show a final example when we have actually more than one async item at queue. Taking into consideration different times of response for those functions.

Collapse
 
cncuckoo profile image
Songfeng Li(李松峰) • Edited

Good demonstration! But a little issue exists in my opinion.

The 1st animation, when the respond() function was pushed to the call stack and executed, the setTimeout() function should be pushed into the call stack (and executed) as soon as possible, instead of waited for about 1 second. Because, as the first and only one line code inside the respond() function, the call to setTimeout( ) should be executed immediately at that time. The second argument of setTimeout(), 1000ms, has only to do with how long the timer should be waiting to add the callback to the task queue, it does not have any effect for when the setTimeout() should be pushed into the call stack.

I wish I had made this little issue clear. btw, the last animation has the same issue too. Thank you.

Collapse
 
devworkssimone profile image
DevWorksSimone

I love gifs! Thanks for explanatio ! Not programming in javascript but was very interesting ti read!

Collapse
 
ijebusoma profile image
Vanessa Osuka

So it's safe to say the purpose of the event loop is to prevent any callback clashes? 🤔

Collapse
 
lydiahallie profile image
Lydia Hallie

Hm no, not really. Imagine we have 4 tasks, and the 2nd tasks needs a delay. If this delay would've happened on the main thread, nothing would've been able to run on the thread while we were waiting:

However, the web api gives us some sort of asynchronous behavior by letting us put stuff "to the side" so to say. We can now keep on running other tasks, thus keeping an interactive UI, while tasks are running in the background:

Hope this somehow made sense haha I just woke up so my illustrations may not be optimal 😜

Collapse
 
stanleysathler profile image
Stanley Sathler

So can we say that preventing callback clashes is the queue's job, instead of event loop's one?

Collapse
 
devworkssimone profile image
DevWorksSimone • Edited

Great!

Collapse
 
hannadrehman profile image
hannad rehman

What if there are no functions is the program?.lets say i have 10 instructions like variable deceleration, assignment , arthematic operations etc. Will all these instructions also go to call stack?
Var a = 10:
Var b;
b = a+ 10;

Collapse
 
jeannotmn profile image
Jeannot MN

These will be executed in the global execution context... which is at the bottom of your call stack

Collapse
 
larsolt profile image
Lars

Awesome, thanks

Collapse
 
henshawsamuel profile image
Samuel Henshaw

I was, currently and still impressed and wowwwwwed by this article. its as if this is the first time i am seeing a Promise.

Great article

Collapse
 
starl441 profile image
STARK

I just can't believe how ellaborate and simple this blog is !!!.This seriously made my day and saved me a lot of time.kudos to the writer!! I specifically created an account to make this comment to support this author.Expecting a lot of concepts to be simplified with gif's.

Collapse
 
jeannotmn profile image
Jeannot MN

Thanks for the detailed post😃.

I have a question regarding this "Luckily, the browser gives us some features that the JavaScript engine itself doesn’t provide: a Web API. This includes the DOM API, setTimeout, HTTP requests, and so on. This can help us create some async, non-blocking behavior 🚀"

Does the Web API allow us to create asynchronous behavior? Doesn't it just give us features that the JS Engine does not have?
Am I wrong saying it's rather the event loop and the callback queue that allow us to create asynchronous behavior?

Collapse
 
ryzhov profile image
Aleksandr N. Ryzhov

Thanks!

Collapse
 
evelynpei profile image
Evelyn Pei

Very helpful in further understanding the event loop! Thanks for posting, Lydia! :)

Collapse
 
avneeshroks profile image
avneeshroks

Hey Lydia! This was amazingly explained! One thing I'm still now able to understand is what's microtasks and macrotasks! How engine prioritize those? Also how the Render/Paint queue work with the Normal queue?

Collapse
 
mohamedlazybob profile image
MOHAMED ZABOUB

I just wanna thank you for this amazing explanation, the first time I've read this 3 months ago, everything was new to me and blur.

Today I went on it again and it's just crystal clear too!

Thank you 3

Collapse
 
gsvidal profile image
Gonzalo

Amazing!, it was so helpful, thanks

Collapse
 
kanxiaoxi profile image
侃小溪

Hi, Lydia Hallie, Thank you for your great work. I want to translate your articles in Chinese to improve my English and skills😊.

Collapse
 
ashimb profile image
A5h1m

Fantastic visualization. Thanks Lydia

Collapse
 
bigleegeek1 profile image
bigleegeek1

As a newbie to learning JS I appreciate your post and look forward to others.

bigleegeek

Collapse
 
gabrielduerto profile image
Gabrielduerto

Muchas Gracias Lydia, aunque no pude entender tu video, el texto esta bien explicado y pude traducirlo, se que tengo que aprender Ingles, tan pronto termine el bootcamp hare un curso intensivo de Ingles, igualmente muchas Gracias por tu Articulo <3

Collapse
 
douglasfugazi profile image
Douglas Fugazi

Super nice explanation. I've learnt new things with this article. Thanks!

Collapse
 
abinash393 profile image
Abinash Panda

what about microtasks?

Collapse
 
indysigner profile image
Markus Seyfferth

Hi Lydia,

such as great and helpful article! Would it be OK with you to translate it into German and to republish it on drweb.de/ (with your author bio, of course)?

Thank you, — Markus

Collapse
 
lydiahallie profile image
Lydia Hallie

Absolutely!

Collapse
 
indysigner profile image
Markus Seyfferth

Thanks so much!

Collapse
 
10secondsofcode profile image
Elango Sundar

Nice awesome articles and visullay explained the event loops :)

Collapse
 
thanhtrung profile image
thanhtrung
  1. The timer runs, in the meantime foo gets invoked and logs First. foo returns (undefined),baz gets invoked, and the callback gets added to the queue.

Image description
I don't understand why it can log undefined in here, can you pls explain more ?

Collapse
 
1option profile image
Maksim Rozhkov

this functions return nothing

Collapse
 
thecodingalpaca profile image
Carlos Trapet

Good stuff, Lydia! You have a very nice and straight-to-the-point way of expressing concepts, I'd love to read some more posts of yours, if you do have any!

Collapse
 
lydiahallie profile image
Lydia Hallie

Will post them soon 😎

Collapse
 
deyvisonrocha profile image
Deyvison Rocha

Nice article! Thanks for share!

Collapse
 
imtiaz_ali_a117e25cc2999e profile image
Imtiaz Ali

I am learning through your github repository Javascript Questions.
The all I have to say you made my life It's helping me alot to understading the javascript.
In one of those questions you shared the link of this article it's just an amazing stuff you shared on github thank you so much.

Collapse
 
dayvster profile image
Dayvster 🌊

You did a fantastic job of explaining and animating this.

Collapse
 
rodolphoasb profile image
Rodolpho Bravo

Hey, Lydia! How have you been? Awesome article!!

Can I translate this article series into Portuguese? (With original author and link, of course).

Collapse
 
ibtesum profile image
Ibtesum Reza Aninda

Image no longer exists!!!!!

Collapse
 
deepak_vishwakarma_b61261 profile image
Deepak Vishwakarma

i read it 1month earlier thank you for quick revision it,s great your written article feel like somebody teaching in front of me easy english

Collapse
 
luckydevboy profile image
Mohammad Reza Ghasemi

Hey Lydia, just wanted to say a huge thank you for this series. I really appreciate it and now I feel like I've got a good grasp on these JavaScript concepts.

Collapse
 
bannie profile image
Bannie&Cloud

Thanks!!!! This article is amazing 👏👏👏

Collapse
 
ajassharafudeen profile image
Ajas

The Best.

Collapse
 
threetowns profile image
leon

Hi, Hallie, I think you can add 'async/await' execute in the gif.

Collapse
 
night_towel profile image
Diana Lozano

Looks like "What the heck is the event loop anyway?" by Philip Roberts | JSConf EU
https://www.youtube.com/watch?v=8aGhZQkoFbQ&vl=en

Collapse
 
gizelads profile image
Gizela Delgado Soto

This is really usuful, the graphics help a lot 🤗

Collapse
 
asuna24 profile image
asuna24

Hi @lydiahallie , thank you for your super comprehensive explanation. All of the gifs are incredible, helped me a lot to understand more about javascript under the hood.

Collapse
 
htetsoemoe profile image
Soe Moe Htet

Thanks for a great article series. 👍

Collapse
 
dangnguyen1004 profile image
DangNguyen

Amazing, really like you visualization

Collapse
 
pratap2210 profile image
Pratap Sharma

Hi @lydiahallie It was an amazing article and animations.

How did you create those animations?

Collapse
 
chideracode profile image
Chidera Humphrey

Super helpful and well written.

Thanks for taking your time to share this with us.

Collapse
 
hieunghiait profile image
Hieu Nghia

nice****

Collapse
 
dostonhack profile image
Doston • Edited

Hello , Lydia Hallie, it is a great article.

Can I translate this article into Uzbek to help more Uzbek developers(With original author and link, of course). too

Collapse
 
itsjatin_kumar profile image
Jatin Kumar • Edited

Very informative. Hats off to the explanation!!!

Collapse
 
zhangbo profile image
zhangbowy

Can I translate your article to a Chinese technical website? , will comment the original link

Collapse
 
kazinoman profile image
kazinoman • Edited

Tnx for your effort.

Collapse
 
prafulla-codes profile image
Prafulla Raichurkar

Wow, nicely explained :D

Collapse
 
tamb profile image
Tamb

You explained this beautifully! Thank you!

Collapse
 
odntht profile image
Fernando Rodrigues

I love it! I’m a visual learner too so this helps a lot! Keep going! o/

Collapse
 
novajay2415 profile image
NovaJay2415

Super helpful! I love this!

Collapse
 
nvminhtu profile image
Tu Nguyen

It is a very visual and great, easy to understand, you saved my life.
Hungry to read these kind of posts.

Love your post!!!!

Collapse
 
capscode profile image
capscode

Wow...
Amazing article for and amazing topic of JS by an amazing writer with an amazing explanation.

thanks for sharing this.

Collapse
 
ehzawad profile image
ehza

This is fantastic!

Collapse
 
robsonmuniz16 profile image
Robson Muniz

Wow, Great Contet, thanks for sharing it!

Collapse
 
mohmmadmoussa1988 profile image
mohmmadmoussa1988

Great Visuals, Thank you

Collapse
 
upasanagithub profile image
Upasana Mahanta

Great article and animations!

Collapse
 
dhananjana profile image
Sachintha Dhananjana

This is a Great job.It makes really easy to understand the concept.

Collapse
 
crazy4groovy profile image
crazy4groovy

Thanks!

Now it time to add the promise's micro queue! :)

Collapse
 
gajjardarshithasmukhbhai profile image
Darshit Gajjar

Great Article Lydia, make this kind of Articles ❤️

Collapse
 
jeffchavez_dev profile image
Jeff Chavez

Wow. This is so helpful since JS is really challenging. Thanks for the effort.

Collapse
 
sonimonish00 profile image
Monish Soni

Thank You so Much !!

Collapse
 
esteban___vera profile image
Esteban Vera

Hi, Lydia!
You are the best!

Collapse
 
eslamsaeed12 profile image
islam saeed

👍 the best one explained event loop ➿

Collapse
 
hcminhit profile image
i love Math

hi Lydia
you mentioned "web API" so what do you mean "web API"? I don't understand what is "web API" , which you are referring to?

Collapse
 
hcminhit profile image
i love Math

Hi, Lydia Hallie
you mentioned "web API" so what do you mean "web API"? I don't understand what "web API" is, which you are referring to?

Collapse
 
vikaschauhan1 profile image
Vikas Chauhan

This is the best article on event loop I have encounter so far.
Thank you so much for making it so wasy for us :-)

Collapse
 
markandersonnc profile image
MarkAndersonNC

Great article. JS is so hard to learn

Collapse
 
ajay08code profile image
ajay08-code

Gifs are so explicit. You really explained everything perfectly

Collapse
 
thisisanish profile image
Anish Agarwal

Glad to find such a gem !

Collapse
 
frances34983772 profile image
Francesca T

Thanks a lot Lydia!

Collapse
 
cagatayunal profile image
Cagatay Unal

Thanks for the great article.

Collapse
 
natespring profile image
Nate Spring

The visualization helps so much! Thank you very much for putting the time into this.

Collapse
 
rhaegar453 profile image
rhaegar453

This is one of the best articles I've seen on Event Loop. Thanks, Lydia for sharing :)

Collapse
 
azeem2793 profile image
Agha Azeem

Fantastic 👍

Collapse
 
_martinjose28_ profile image
martin jose

And finally i started to understand how the event loop works, thanks a loooot. I've been reading for days feeling confusing. Great job with those gif, love it.

Collapse
 
sudharsanansr profile image
Sudharsanan Ravichandran

This is a great article, thanks for sharing!

Collapse
 
princebuchi12 profile image
Prince Buchi

Wow

Collapse
 
trangchongcheng profile image
cucheng

Nice, thank for you...love you <3

Collapse
 
perpetual_education profile image
perpetual . education

Great job! Here's a deep dive from another presenter: latentflip.com/loupe - and with a live app to show the visualizations.

Collapse
 
rschneider94 profile image
Rodrigo Schneider

Thanks for this article and also the others. Awesome explanation and awesome GIFs! Cool idea. I hope you have a nice day! :)

Collapse
 
diebythelaw profile image
Vandstein

Thank you for sharing, it's really interesting!

Collapse
 
nhuthuynh profile image
NhutHuynh

Great article, amazing animations makes me understand the topic easily.

Collapse
 
gislenejs profile image
Gislene Carvalho

It's a gift of the Gods for a visual learner like me. Thanks for this ultra helpful article.

Collapse
 
djangotricks profile image
Aidas Bendoraitis

These series are such a pearl. Thanks for creating them. I am very happy to have found them.

Collapse
 
karthikaruna profile image
Karthikeyan A.

Hey Lydia, what about event listeners/callbacks? How do they work internally?

Collapse
 
iakgoog profile image
Sutthinart Khunvadhana

Fantastic article. Love the way you explain things step-by-step.

Collapse
 
kuscamara profile image
Kus Cámara

Great post! Worths mentioning the job or microtask queue (promises) that has higher priority than the callback queue.

Collapse
 
jameslam profile image
jameslam

Great article, thanks! Could you please explain macro task and micro task in this visual way? It can definitely help others!

Collapse
 
atilacamurca profile image
Átila Camurça Alves

Great article!

Have you heard of loupe? latentflip.com/loupe/

Collapse
 
sarah_chima profile image
Sarah Chima

Super clear explanation. Thanks for sharing this.

Collapse
 
mustafaensar profile image
Mustafa Ensar

Hi Lydia Hallie,

I'm gonna make a presentasion and tell this subject to other students like me in my class. Can I use your gif images :)

Collapse
 
svsharma profile image
Shriram Sharma

Lydia, thank you for breaking this down for us! As a visual learner, this is gold!

Collapse
 
juliosaraiva profile image
Julio Saraiva

Awesome. Great Job!

Collapse
 
wlsdud2194 profile image
JinYoung-Lee

Super nice article. Thank you for writing the post😊

I want to translate this post series into Korean. May I do this leaving the link and original author?

Collapse
 
yamanchinu profile image
Yaman Agrawal

Lydia, big thanks, I have been coding for a while now, always wished I had some visual guidance at the start of my career and here you are. BIG THANKS AND HUGE RESPECT.

Collapse
 
didof profile image
Francesco Di Donato

Hello Lydia,
I really appreciate you piece of work. Congratulations.

Collapse
 
paras594 profile image
Paras 🧙‍♂️

good good good...these visualizations are fabulous !!

Collapse
 
idaeun profile image
Daeun Kang

Hi, thank you for great article.
Can I translate this series into Korean in my blog? (of course with original author & link)

Collapse
 
diepvv profile image
diepvv

Hi, Lydia, it is a great article.

Collapse
 
laerciolopesll profile image
LaercioLopesLL

Images off

Collapse
 
prasathmani profile image
Prasath

The article is excellent and the video explanation is truly remarkable.!

Collapse
 
kirankamath96 profile image
Kiran Kamath

Why does event loop makes sure the call stack is empty , if there is already a callback function inside queue waiting to be invoked?

Collapse
 
ksdeveloper profile image
kuldeep patel

I really love this article...
My mind is blown. 🤯
😅
This article is very used fully for me. Thank you Lydia Hallie. 🙂

Collapse
 
jongeunk0613 profile image
Jongeun Kim

Hi, Lydia.
Your article was of great help in understanding javascript.

Could I upload your article in Korean translation?
It would greatly help other Korean developers !!

Collapse
 
sebasqui profile image
SebasQuiroga

Great article Lydia!

Collapse
 
ximbal profile image
EN

Great Series! Love them, what did you use to create your animations?

Collapse
 
tranduchoa profile image
Trần Đức Hòa

Great article! Thanks.

Collapse
 
bilalniaz15 profile image
Bilal Niaz

Hi, Lydia Hallie, it's good article

Collapse
 
khaledalwakel profile image
khaled-alwakel

thank you so much . it was very helping ..

Collapse
 
rmfranciacastillo profile image
Renato Francia Castillo

This is so COOL! What did you used in order to do the animations?

Collapse
 
swtpumpkin profile image
JeongwonKim

Hi.
This is interesting article!!!
So, i want translate Korean.....
Is it possible?

Collapse
 
onsdiweni profile image
ᴏɴᴇꜱ ᴅɪᴏᴜᴀɴɪ

Great article
Thanks Lydia

Collapse
 
orashus profile image
Rash Edmund Jr

thanks @lydiahallie

Collapse
 
hagayhaut profile image
Hagay Haut

Thanks for putting these together! I've been reading about some of this stuff and this really helps it click.

Collapse
 
prajwalscorpionking123 profile image
PRAJWAL PATIL

Nicely explained.. thank you so much

Collapse
 
abdallahsamir96 profile image
Abdallah Samir

please i need to know how it works with more than async operation
such as 2 of setInterval or 2 of setTimeout

Thank you

Collapse
 
ramy5 profile image
Ramy Al-Sabry

Hi, Lydia Hallie, it is a great article.
Thanks so much, finally i understand it.

Collapse
 
anilloutombam profile image
Anil Loutombam

The GIF you put just, make my things so loud and clear, thank you so much.

Collapse
 
kamilacode profile image
Kamila Santos Oliveira

awesome content!

Collapse
 
oussabay profile image
Oussama

very insightful thank you

Collapse
 
karthikaruna profile image
Karthikeyan A.

Lydia, what about event callbacks like click, scroll. How do they work?

Collapse
 
ghostmaysam1 profile image
Maysam

wow!

Collapse
 
edgarmc100 profile image
EdgarMC100

This article helped me to remember what I read in a book in just 5 minutes, thanks Lydia. I consider myself a visual learner.

Collapse
 
donjudeeng profile image
Don Jude Joseph

Thank you Lydia Hallie fo this article

Collapse
 
marinaandthecode profile image
Marina

Thanks a lot! It doesn't look scary anymore

Collapse
 
devidmaul9990 profile image
Devidmaul

Still learning Java. It's little bit difficult for me. I used it on my project Infinite Craft

Collapse
 
hossammuhammedomar profile image
Hossam Omar

great article, thank you very much

Collapse
 
sauliusp profile image
Saulius

Superb!

Collapse
 
esterkaufman profile image
Ester Kaufman

Hi, Lydia, i think this is the best post to get the JS loop behind the scenes.

Can I translate this post, and publish it on my blog, with credits to the author and direct link?
Thanks for posting!

Collapse
 
dinhkhiemtran profile image
Khiêm

Awesome!

Collapse
 
elamiir profile image
El-amiir

Great article, Thanks.