JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue

Learn how the browser event loop, task queue, microtask queue, and Web APIs work together to enable non-blocking, asynchronous JavaScript.
- / lydiahallie
- buymeacoffee.com/lydiahallie
- / lydiahallie
- / lydia-hallie
- / theavocoder
Timestamps:
0:00 Intro
0:32 Call Stack
1:18 Single-threaded Problem
2:01 Web APIs
2:47 Callback-based APIs
4:04 Task Queue
4:39 setTimeout
6:22 Microtask Queue
8:40 Promisifying Callbacks
8:57 Challenge
10:52 Recap
11:58 Outro

Пікірлер: 994

  • @theavocoder
    @theavocoderАй бұрын

    Btw if you're in a hurry you can just fast-forward to 10:52 haha! I use Apple Keynote for everything. 💡Just a heads up: I explain these concepts in a way that personally helped me conceptualize the processing order. E.g. the event loop doesn't directly "prioritize" the microtask queue, rather they're just processed and completed before the event loop continues to the next task. One iteration of the event loop is executing a single task, processing all available microtasks, and then updating the rendering of the page if needed (that's not covered in this video, might be another video, things like requestAnimationFrame). However, within your code, you'll get the sense that the microtasks are "prioritized" over the task queue-based parts.

  • @sadatarefinrafat

    @sadatarefinrafat

    Ай бұрын

    Gotta love you for respecting our time.

  • @swaminathbera6407

    @swaminathbera6407

    Ай бұрын

    From where did you learn?

  • @sourabhjana1278

    @sourabhjana1278

    Ай бұрын

    Can you please extend this more to explain NodeJS runtime 🙏

  • @inowatchvideos

    @inowatchvideos

    Ай бұрын

    Those slides are wonderful, it’s still a mystery to me how they are so good. Skills.

  • @joshuafontiveros7877

    @joshuafontiveros7877

    Ай бұрын

    Thank you for doing this. I love the visuals you made here!

  • @bilalarain4632
    @bilalarain463228 күн бұрын

    i think thousands of senior developers finally understood it today.

  • @DasBeatz

    @DasBeatz

    22 күн бұрын

    🤯

  • @scryptum

    @scryptum

    20 күн бұрын

    fake senior developers. No theory , not a real dev!

  • @KAIDO-mi1tr

    @KAIDO-mi1tr

    19 күн бұрын

    Knowing the todays reality, you wanted to say "junior" developers ? : )

  • @bilalarain4632

    @bilalarain4632

    19 күн бұрын

    @@KAIDO-mi1tr haha

  • @yangliu2713

    @yangliu2713

    11 күн бұрын

    now adays, senior and junior have similar salary, so whats the difference

  • @carltongordon
    @carltongordonАй бұрын

    Where has this channel been all my life?

  • @pawanpulami6091

    @pawanpulami6091

    Ай бұрын

    Exactly I was thinking the same 😂

  • @peacemurder3778

    @peacemurder3778

    Ай бұрын

    In the future obviously. 😂

  • @riccardoguitar

    @riccardoguitar

    Ай бұрын

    She already done a longer vid for freeCodeCamp 2 years ago and she's on FrontedMasters as Teacher kzread.info/dash/bejne/qpefqpesY7jbiJc.html

  • @theblackelephant

    @theblackelephant

    Ай бұрын

    Same here❤❤❤❤❤

  • @pubudusenarathne

    @pubudusenarathne

    Ай бұрын

    Exactly!!

  • @ryandawson1220
    @ryandawson1220Ай бұрын

    I have been programming for 15 years and I don't think I have seen information presented so succinctly in that span. Thank you so much for this.

  • @fadichamieh

    @fadichamieh

    29 күн бұрын

    100%

  • @prinzadamz

    @prinzadamz

    12 күн бұрын

    Absolutely 🤟

  • @florianwicher
    @florianwicher11 күн бұрын

    This video should receive the Oscar for best animation

  • @timurdinov7452
    @timurdinov745211 күн бұрын

    If anyone had a question in the Challenge section as to why console.log(1) didn't execute immediately, even though it was in the Microtask Queue and the Call Stack was empty, read on. All the code on the left is a script and can be represented as an anonymous function. At the very beginning of the "Challenge" section in the Call Stack, there should have been an "anonymous" block. This block starts executing (the script is being executed), and then everything is the same as in the video, except that the "anonymous" block is always at the bottom of the Call Stack. The "anonymous" block disappears from the Call Stack after console.log(5) is executed, because it is the last operation in the script. And so when the "anonymous" block disappears from the Call Stack, Microtask Queue and Task Queue processing starts (10:04). Great video!

  • @joshpike

    @joshpike

    9 күн бұрын

    Thank you. Absolutely wondered this.

  • @akashrajum3319

    @akashrajum3319

    Күн бұрын

    Yep, the anonymous block is referred to as Global Execution Context

  • @jamesallen74
    @jamesallen74Ай бұрын

    I've been in software development for 16 years. This video is outstanding. Probably one of the best I've ever seen for JavaScript. Lydia, I want to encourage you to keep doing these if you desire. This visual, animated approach combined with your ability to teach is a home run. Thank you so much for doing this. I am now subscribed.

  • @draco_2727

    @draco_2727

    Ай бұрын

    9 years ago was this video... her video seems a rip-off kzread.info/dash/bejne/apV7yryKm9KskrQ.html&ab_channel=JSConf

  • @TheNomadsTimeCapsule

    @TheNomadsTimeCapsule

    Ай бұрын

    I can only agree. Especially for this topic, it was hard to find such an amazing explanation. You really helped me out. Thank you,

  • @modolief

    @modolief

    Ай бұрын

    ditto

  • @Ainigma
    @AinigmaАй бұрын

    @Lydia Hallie Are you kidding? This level of detail, every animation, every transition, the highlighting (and temporarily hiding unimportant components) is just so good. Very well done, love it.

  • @chensu4732
    @chensu4732Күн бұрын

    This is excellent work, Lydia! Your visualization of the event loop definitely can help millions of JS engineers understand it better. Huge impact, congratulations!

  • @amulpatel
    @amulpatelАй бұрын

    it is very very rare to have material like this presented in such a visual and engaging way .. animation is hardly ever used in js tutorials. Visualization of these concepts is so important for the visual learners out there. THANK YOU. instantly subscribed.

  • @ramlaaal
    @ramlaaalАй бұрын

    wow the visualization is awesome. The colours, gradients, design and animation. Its perfect down to the tiny details.

  • @ahmedmaaz4390
    @ahmedmaaz439025 күн бұрын

    Okay ma'am, I noticed you only have 3 videos on your channel. Don't stop until you have at least a 20 video playlist on your channel. This is gold.

  • @huycaoviet8367
    @huycaoviet8367Ай бұрын

    I finally understand Event Loop after 1 year writing JS.

  • @ericjeker

    @ericjeker

    Ай бұрын

    Don't worry, many devs still don't understand it after 10 years of writing JS.

  • @jonniem

    @jonniem

    Ай бұрын

    I thought I did… until today😅

  • @lamhung4899

    @lamhung4899

    Ай бұрын

    No you do not 😂

  • @chess4964

    @chess4964

    Ай бұрын

    huh do you need to understand it? coding js/ts for 3 years now

  • @dbzfan2487

    @dbzfan2487

    15 күн бұрын

    Then you're a shit developer tbh

  • @kaipang-whitsett2379
    @kaipang-whitsett2379Ай бұрын

    This is the type of visualization that coding vids need

  • @AndrewTSq

    @AndrewTSq

    Ай бұрын

    it reminds me of debuggers we used to have in the late 80ies

  • @TC14
    @TC14Ай бұрын

    Top tier presentation, this is easily one of the best visualizations I've seen on KZread. You clearly have excellent teaching and communication skills. I know you are focusing your content on JavaScript but if you were ever interested in giving us an overview of some of your presentation techniques in Apple Keynote, I think many viewers could greatly benefit from it. Keep up the awesome content! I can't wait to see what videos you have in store for this channel.

  • @scaly86
    @scaly86Ай бұрын

    The sign of mastery is being able to simply explain a complicated concept. This preso is a thing of beauty... and mastery!

  • @someshkarmakar47
    @someshkarmakar474 күн бұрын

    One of the best video on event loop, till now on youtube, words are not enough to appreciate it... really... thank you...

  • @slevinstayshere
    @slevinstayshereАй бұрын

    I'm a web programmer for 15+ years now and I'm stunned how well made this explanation is. really Amazing! Subscribed right away!

  • @CrusaderMen
    @CrusaderMenАй бұрын

    Thank you. This is the best explanation I've seen.

  • @Kurogane-el2vq
    @Kurogane-el2vq7 күн бұрын

    This is so important in JavaScript! Finally someone made a good video topic on this. Made me understood the call stack so clearly.

  • @AaronAsherRandall
    @AaronAsherRandall4 күн бұрын

    I have no words. I’ve never seen a coding, programming or any kind of software dev video this well laid out! Your visuals and your ability to “talk shop” are both incredible. If you sell a course, I’d buy it immediately.

  • @Isaac-hd6vs
    @Isaac-hd6vsАй бұрын

    Hands down, the best event loop explanation ever!

  • @MagnumCarta
    @MagnumCartaАй бұрын

    10 / 10 quality. The explanation of the different queues helped clear up confusion I had in the background of how asynchronous tasks work underneath the hood in the context of Javascript. Even with a bachelor's degree in computer science it was still a pretty head scratching concept thinking "how does the engine know what is I/O blocking and what is not? How does it handle that?". I would always hear "oh its just on the event loop! Its just on the event loop!" but I'd be like "all these diagrams suggest the blocking and non-blocking are on the same queue". I had no idea about the microtask queue and that is where fetch's then calls are appended to. Also I can't help but look at the word "event loop" and just think of Froot Loops.

  • @paulobelucci
    @paulobelucci7 күн бұрын

    Amazing. I'm a visual learner, and it was a pleasure to watch and learn. Thank you for the content. 👏🏻👏🏻👏🏻

  • @_nsikak
    @_nsikak9 күн бұрын

    You made it easy for me to understand the sequence of execution between the microtask queue and task queue. Thank you!

  • @leepaulison4928
    @leepaulison4928Ай бұрын

    Lydia, your teaching style is the best I've seen. Please continue to educate us.

  • @HamzaKhan-rs2yo
    @HamzaKhan-rs2yoАй бұрын

    The visualization is outstanding, providing one of the clearest and most informative explanations I've come across.

  • @tomjerry0796
    @tomjerry07969 күн бұрын

    12 min just recalled my last 2 years ❤🎉

  • @rjwhite4424
    @rjwhite442415 күн бұрын

    this single video has taught me more about js under the hood then months of watching other videos

  • @jackwright517
    @jackwright517Ай бұрын

    Whoaaaa... Ive been writing js for years and this is hands down the BEST event loop video resource ive ever seen. My god its presented so simply! 💯

  • @forkanshanto2228
    @forkanshanto2228Ай бұрын

    This video brilliantly illustrates the intricate workings of JavaScript's Event Loop, Web APIs, and (Micro)task Queue. The visuals make complex concepts crystal clear, making it easier to grasp how JavaScript manages asynchronous tasks behind the scenes. Kudos to the creators.

  • @Software..Engineer
    @Software..Engineer29 күн бұрын

    one of the best video on javascript visulization. thank you lydia Hallie. Make more videos like this.

  • @danielwilkowski5899
    @danielwilkowski5899Ай бұрын

    I can't believe, there is literally not one incorrect word here. Amazing.

  • @mattpocockuk
    @mattpocockukАй бұрын

    Fucking hell Lydia, this is incredible

  • @theavocoder

    @theavocoder

    Ай бұрын

    Ah thank you Matt! 🙏

  • @hellcat8886
    @hellcat8886Ай бұрын

    Pls, don't stop making videos like this, it's really enlightening!❤

  • @PostMeridianLyf
    @PostMeridianLyfАй бұрын

    Are you Ai? This seems too perfect

  • @The_Wookiee

    @The_Wookiee

    Ай бұрын

    *too (This has been your ai powered nostalgia post troll, have a nice day.)

  • @abdulrahmantahir3033
    @abdulrahmantahir3033Ай бұрын

    Mam can you make a video on how exactly the react works under the hood ?

  • @siddheshbhosale9820

    @siddheshbhosale9820

    Ай бұрын

    This is the best topic

  • @oudinia1
    @oudinia18 күн бұрын

    This video is way better than watching my favorite golden buzzer artist for the first time. Off the charts explanation. This video has just made history. Thank you so much. I had gone through a similar tutorial, yet, this one is so easy to follow.

  • @souravmitra6370
    @souravmitra63706 күн бұрын

    Best possible explanation out there for understanding event loop concept in JS. Thanks for the video.

  • @paulopontovaz
    @paulopontovaz26 күн бұрын

    Whoa, I'm so happy that this channel exists. The visuals help SO MUCH with understanding all the JS flow!

  • @thepassionatecoder5404
    @thepassionatecoder540416 күн бұрын

    God bless you Lydia. Hands down the most important and enlightening JavaScript tutorial on the KZread that every serious JavaScript developer needs. God

  • @onlysparsh
    @onlysparsh13 күн бұрын

    Got it right ! Once you understand the basics this is the best video ever to understand how the event loop and overall js engine execution work ! Thanks lydia

  • @SaiPrakash16
    @SaiPrakash16Ай бұрын

    By far the most simple yet effective way to show event loop . Really enjoyed it

  • @rogue.ganker
    @rogue.ganker7 күн бұрын

    Been doing javascript for over a decade, and this was the coolest explanation I've ever seen!

  • @adamcarroll3498
    @adamcarroll34988 күн бұрын

    Where was this video when I was doing interviews 2 months ago 😆 An incredible video, really useful and clear. Thank you and well done 👏

  • @marcoscabrinirianidosreis6655
    @marcoscabrinirianidosreis66556 күн бұрын

    This channel is a gold mine, thanks for sharing it, this is amazing

  • @swayze_0
    @swayze_04 күн бұрын

    Amazingly simple explaniation and satisfying graphics! Really thankful for this video. Keep it up!

  • @viatrixhd
    @viatrixhdАй бұрын

    I have been programming for some years now, as a visual learner this video was awesome. Perfectly visualized and straight to the point! Keep up the great work

  • @itsjmendez
    @itsjmendez13 күн бұрын

    Well done! the best way to understand these concepts is with a visual explanation. Keep it up! 🔥

  • @bagheldevansh
    @bagheldevansh25 күн бұрын

    it took me way to long to find a video that explained everything this well

  • @junior.santana
    @junior.santana8 күн бұрын

    I didn't know this was possible but this video is JavaScript meets Absolute Cinema

  • @arthurvmdantas
    @arthurvmdantas14 күн бұрын

    This presentation is crazy good. I can only imagine the amount of work put into it. Congratulations.

  • @hosampb5593
    @hosampb5593Күн бұрын

    I've just came across your channel. Very concise, informative and pleasantly visualised. Also interesting topic!

  • @gabriellinassi3382
    @gabriellinassi3382Ай бұрын

    Thank you, Lydia. You explain very well. After 3 years writing JS, I'm finally taking the time to go back to the basics and learn the fundamentals and I'm learning a lot

  • @dada78641
    @dada7864125 күн бұрын

    These are the most gorgeous looking slides... ever.

  • @basilenordmann7356
    @basilenordmann73569 күн бұрын

    Okay it doesn’t look like me to just stupidly show appreciation, but this video is straight up great

  • @flnnx
    @flnnxАй бұрын

    I'm preparing for an interview and this helps a lot. The promises video and this one are simply incredible. Love the series.

  • @stratfanstl
    @stratfanstl8 күн бұрын

    Very well done. When learning a new language or framewor, I try to assemble similar box diagrams showing how config and references tie across different code modules to achieve a result. It takes enormous amounts of work to devise examples that are small enough to support summarization while still demonstrating the functionality. Tying them together in code dependency order or execution order is yet another challenge to do well. Your videos do both extremely well. Subscribed!

  • @DesignsbyBlanc
    @DesignsbyBlancАй бұрын

    Never thought I grab some popcorn🍿 to learn about the inner workings of JavaScript, yet here I am. Awesome work!

  • @meetfilipe_
    @meetfilipe_Ай бұрын

    I can't imagine the amount of work you put in to explain something so complex put so simply

  • @TheDogn
    @TheDognАй бұрын

    I've never seen this information provided with such uncompromising clarity. Subbed. This is the first video I've seen of yours, but if the rest are anything like this one, you're worth it. Amazing.

  • @erick2051
    @erick205120 күн бұрын

    Lydia, your explanation is by far the clearest i've seen out there. I'd love to watch something similar for async-await!

  • @tylerwalton7659
    @tylerwalton765912 күн бұрын

    This was absolutely amazing!! The way you broke down callbacks from methods, visuals to see what’s happening. Best of all a challenge to really help drive the subject home, best way to improve learning. I can’t wait for more to come from you and THANK YOU!

  • @GUYX10
    @GUYX1028 күн бұрын

    One of the best explainer videos I've ever seen, thank you! Subbed

  • @glyakk
    @glyakk14 күн бұрын

    It is insane how much information you you were able to convey in one short video, I knew async tasks were pushed off to be filled later but I had no mental model how that worked until now.

  • @aGoodOmen
    @aGoodOmenАй бұрын

    I am in awe of the explanation and the masterful use of Keynote. Great stuff. Congrats!

  • @mohitkarki7185
    @mohitkarki718524 күн бұрын

    I think this is the best event loop explanation in the internet. You have described each and every point in such detailed way, making this topic feel so simple to understand. The animation is also made with such detail, making life easier.

  • @geoffreymoluba7448
    @geoffreymoluba7448Ай бұрын

    It's so well explained that after 1minutes 27 seconds of watching I had to subscribe. This is pure quality content

  • @marianopainefil3537
    @marianopainefil3537Ай бұрын

    Este video es INCREIBLE. Completamente deberia ser un MUST en cualquier capacitación/universidad. Millones de gracias!

  • @checkerface0-0
    @checkerface0-0Ай бұрын

    I had seen a Holy Grail of profound knowledge to javascript! ALL HAIL LYDIA!

  • @DontFollowZim
    @DontFollowZim25 күн бұрын

    I've already learned all this, but this is the probably the clearest, best, and most beautiful explanation I've seen. I need to share this...

  • @nelsonelijah5327
    @nelsonelijah532727 күн бұрын

    This is phenomenal. I just started learning javascript coming from an Embedded systems background and never understood how the execution of commands happened. This cleared a year of misconceptions for me and unprecedented years of troubles. Wow! Some people are just goated!

  • @kamhawy
    @kamhawy5 күн бұрын

    Well explained with smooth & meaningful animation. Awesome 👏👍

  • @matejzajacik8496
    @matejzajacik8496Ай бұрын

    I don't even use JS in my line of work, ever, but the beautiful animations and colors caught my eyes, so I watched it and learned quite a bit about JS. :) Very well put together!

  • @IceBreakerGamer
    @IceBreakerGamer18 күн бұрын

    This channel is a gold mine... literally.. please post more.

  • @EbrahimTahernejad
    @EbrahimTahernejadАй бұрын

    I already knew all these but still watched it because of the quality of your presentation. Great work. Keep doing what you're doing.

  • @matickovac
    @matickovac19 күн бұрын

    Legend. Easily one of the best videos on JS on YT!

  • @ylaguardia
    @ylaguardiaАй бұрын

    Congrats on this video. I've read a lot about this topic... articles, tweets, book passages. I've seen videos and talks about this. None of them were so thorough, clear and enlightening as this one. Keep up with the outstanding work!

  • @t.k.raphaelngan6002
    @t.k.raphaelngan6002Ай бұрын

    Glad to be more clear about async stuff. Before just confused with the sequence and did not know why. Not even heard terms of promise based and callback based and their respectively being thrown to microtask queue and general task queue. Thanks 👏

  • @pryansh_
    @pryansh_Ай бұрын

    I were to make notes on my notion for this.. but adding just the youtube link.. Best explanation on entire Internet by a great margin. Subscribed !

  • @user-so4kv5oo5d
    @user-so4kv5oo5dАй бұрын

    Lydia, I want to encourage you to keep doing these if you desire. This visual, animated approach combined with your ability to teach is a home run.

  • @edupazz
    @edupazz3 күн бұрын

    GREAT EXPLANATION Something that wasn't very clear to me first time learning JS is that JS is just a thin layer of abstraction of a huge complex software that the browser is. Web APIs are NOT executed by the JS engine, but by the browser, which mostly execute C/C++ code. JS is just a tool tailored to do I/O operations effectively. i. e. most of the code you write in JS is just delegating tasks to the browser, it's not "pure" JS. One may ask "why monothread?". Because multithreading sucks. It's a design decision. Given most of complex work is done by the browser internals, and to make working with web apps a bit more pleasant, JS follows a simpler yet effective model, this model being the event loop. i. e. you don't have to care about race condition and stuff in JS, just code asynchronously, relying that the browser will do the heavy lifting

  • @warta312
    @warta31222 күн бұрын

    Hope you keep doing this great job. This is one of the best explanations I've seen in the last few months.

  • @foursixnine
    @foursixnineАй бұрын

    YISUS!!!! Piling up on what everybody else says: This video is amazing! I loved the video, and specially the visualization of the calls! Even if I don’t do Javascript anymore, this is so useful even for other languages, specially those based on a virtual machine or runtime! Thank you!

  • @112_akmalmahardikanp8
    @112_akmalmahardikanp813 күн бұрын

    i often use "feeling" to say "maybe this work like this", finally your video with the visualization make me say "ahh so that how its work". Amazing Video

  • @eyeiaye
    @eyeiaye25 күн бұрын

    You've broken this down so simply that I'm surprised this isn't the standard model for teaching this. I don't deal with js a ton so you've helped explain behaviors I had witnessed but never fully understood, thank you!

  • @JoysterRodrigues7
    @JoysterRodrigues7Ай бұрын

    The presentation quality is top-notch! This is probably the best JS "under-the-hood" explainer out there

  • @WebQrious
    @WebQrious12 күн бұрын

    this is the best ever explanation i've ever seen... Thank you for this amazing video

  • @SanketBhat7
    @SanketBhat7Ай бұрын

    So far the best explanation of how Java script works. Thanks

  • @noozytechz
    @noozytechz28 күн бұрын

    What you've done is mind-blowing, ma'am.

  • @sebas_xs
    @sebas_xsАй бұрын

    Your explanations are crystal clear and your slides are absolutely stunning! You have a real talent for breaking down complex topics in such an engaging way. Keep up the fantastic work, you're making learning an absolute pleasure!

  • @teleprint-me
    @teleprint-meАй бұрын

    This video showcases a true understanding of the web api and the javascript event system resulting in a extremely high quality presentation.

  • @hoangduy500
    @hoangduy500Ай бұрын

    This channel is a precious gem! Thank you, Lydia. I know it takes a lot of effort, but I hope you could make more videos with excellent visual explanations like this.

  • @suenkaiching1580
    @suenkaiching1580Ай бұрын

    Thank you! This is absolutely the best explanation I have ever seen. 12 mins of video cleared out all the my confusions I had in event loop from day 1!!

  • @lmarts
    @lmartsАй бұрын

    Wow! I'm surprised at how well the JavaScript asynchronous lifecycle is explained in this video. The best of its kind bar none.

  • @vikramtatke5930
    @vikramtatke5930Ай бұрын

    This is absolute gold! So glad KZread recommended this video. Lydia, it is amazing to see the effort you've put into creating these slides. I subscribed in the first 60 seconds. This is how the universities should have taught us! Kudos! Looking forward to your next one!

  • @haraseesgill8491
    @haraseesgill8491Ай бұрын

    This is a really great resource for learning the importance of the event loop. This is the perfect medium between deep technical understanding and practical application of the event loop and Javascript as a whole. Even though I knew all of this, I found it refreshing relearning with the way you organized information, and I even forgot about the Microservice queue so that cleared up some of my async JavaScript understanding. This was an awesome watch! Looking forward to your future explanations/animations. Please keep it up 😁

  • @MM-ts9jy
    @MM-ts9jy28 күн бұрын

    I must say, this is the best visual representation of JS I've seen so far

  • @ashuvssut
    @ashuvssutАй бұрын

    No BS just pure content! True GEM!! Subscribed right away at 4:22 These small concepts took me a long time to grasp while working with JS over the years

  • @augustineakotolarbi-ampofo6769
    @augustineakotolarbi-ampofo676926 күн бұрын

    The best explanation I've ever seen on this topic. I'm not sure if the visualization was the key or not, but your explanation was also impeccable. Subscribed! 🛎