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

Поделиться
HTML-код
  • Опубликовано: 14 июн 2024
  • 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

Комментарии • 1 тыс.

  • @theavocoder
    @theavocoder  2 месяца назад +170

    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 2 месяца назад +4

      Gotta love you for respecting our time.

    • @swaminathbera6407
      @swaminathbera6407 2 месяца назад

      From where did you learn?

    • @sourabhjana1278
      @sourabhjana1278 2 месяца назад +2

      Can you please extend this more to explain NodeJS runtime 🙏

    • @inowatchvideos
      @inowatchvideos 2 месяца назад +2

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

    • @joshuafontiveros7877
      @joshuafontiveros7877 2 месяца назад

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

  • @bilalarain4632
    @bilalarain4632 Месяц назад +327

    i think thousands of senior developers finally understood it today.

    • @DasBeatz
      @DasBeatz Месяц назад

      🤯

    • @scryptum
      @scryptum Месяц назад +3

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

    • @KAIDO-mi1tr
      @KAIDO-mi1tr Месяц назад +3

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

    • @bilalarain4632
      @bilalarain4632 Месяц назад

      @@KAIDO-mi1tr haha

    • @yangliu2713
      @yangliu2713 29 дней назад

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

  • @carltongordon
    @carltongordon 2 месяца назад +562

    Where has this channel been all my life?

    • @pawanpulami6091
      @pawanpulami6091 2 месяца назад +2

      Exactly I was thinking the same 😂

    • @peacemurder3778
      @peacemurder3778 2 месяца назад +8

      In the future obviously. 😂

    • @riccardoguitar
      @riccardoguitar 2 месяца назад +9

      She already done a longer vid for freeCodeCamp 2 years ago and she's on FrontedMasters as Teacher
      ruclips.net/video/xckH5s3UuX4/видео.html

    • @theblackelephant
      @theblackelephant 2 месяца назад +1

      Same here❤❤❤❤❤

    • @pubudusenarathne
      @pubudusenarathne Месяц назад

      Exactly!!

  • @ryandawson1220
    @ryandawson1220 Месяц назад +256

    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.

  • @florianwicher
    @florianwicher 28 дней назад +28

    This video should receive the Oscar for best animation

  • @jamesallen74
    @jamesallen74 2 месяца назад +279

    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 2 месяца назад

      9 years ago was this video... her video seems a rip-off
      ruclips.net/video/8aGhZQkoFbQ/видео.html&ab_channel=JSConf

    • @TheNomadsTimeCapsule
      @TheNomadsTimeCapsule 2 месяца назад +6

      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 Месяц назад +1

      ditto

  • @Ainigma
    @Ainigma Месяц назад +66

    @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.

  • @amulpatel
    @amulpatel Месяц назад +27

    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 Месяц назад +37

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

  • @timurdinov7452
    @timurdinov7452 28 дней назад +18

    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 26 дней назад +2

      Thank you. Absolutely wondered this.

    • @akashrajum3319
      @akashrajum3319 18 дней назад

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

  • @scaly86
    @scaly86 Месяц назад +5

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

  • @aleksanderkrolasik1895
    @aleksanderkrolasik1895 4 дня назад

    This presentation is a pinnacle of visual communication. We are dealing here with a highly organized mind.

  • @ahmedmaaz4390
    @ahmedmaaz4390 Месяц назад +5

    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.

  • @kaipang-whitsett2379
    @kaipang-whitsett2379 2 месяца назад +15

    This is the type of visualization that coding vids need

    • @AndrewTSq
      @AndrewTSq 2 месяца назад

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

  • @slevinstayshere
    @slevinstayshere Месяц назад +6

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

  • @TC14
    @TC14 2 месяца назад +23

    Top tier presentation, this is easily one of the best visualizations I've seen on RUclips. 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.

  • @Isaac-hd6vs
    @Isaac-hd6vs Месяц назад +5

    Hands down, the best event loop explanation ever!

  • @huycaoviet8367
    @huycaoviet8367 2 месяца назад +66

    I finally understand Event Loop after 1 year writing JS.

    • @ericjeker
      @ericjeker 2 месяца назад +18

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

    • @jonniem
      @jonniem 2 месяца назад +4

      I thought I did… until today😅

    • @lamhung4899
      @lamhung4899 2 месяца назад +2

      No you do not 😂

    • @chess4964
      @chess4964 2 месяца назад +1

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

    • @dbzfan2487
      @dbzfan2487 Месяц назад

      Then you're a shit developer tbh

  • @CrusaderMen
    @CrusaderMen 2 месяца назад +23

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

  • @MagnumCarta
    @MagnumCarta 2 месяца назад +8

    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.

  • @HamzaKhan-rs2yo
    @HamzaKhan-rs2yo 2 месяца назад +5

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

  • @leepaulison4928
    @leepaulison4928 2 месяца назад +4

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

  • @forkanshanto2228
    @forkanshanto2228 2 месяца назад +3

    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..Engineer Месяц назад +1

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

  • @paulopontovaz
    @paulopontovaz Месяц назад +1

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

  • @jackwright517
    @jackwright517 2 месяца назад +3

    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! 💯

  • @vasili551
    @vasili551 9 дней назад

    can not be simpler and more elegant way of showing the concepts, thanks for the lessons.

  • @SaiPrakash16
    @SaiPrakash16 2 месяца назад +2

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

  • @mattpocockuk
    @mattpocockuk 2 месяца назад +14

    Fucking hell Lydia, this is incredible

    • @theavocoder
      @theavocoder  2 месяца назад +1

      Ah thank you Matt! 🙏

  • @abdulrahmantahir3033
    @abdulrahmantahir3033 2 месяца назад +8

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

  • @tomjerry0796
    @tomjerry0796 27 дней назад +1

    12 min just recalled my last 2 years ❤🎉

  • @rjwhite4424
    @rjwhite4424 Месяц назад +1

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

  • @PostMeridianLyf
    @PostMeridianLyf 2 месяца назад +13

    Are you Ai? This seems too perfect

    • @The_Wookiee
      @The_Wookiee Месяц назад +1

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

  • @mohitkarki7185
    @mohitkarki7185 Месяц назад

    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.

  • @arthurvmdantas
    @arthurvmdantas Месяц назад

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

  • @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

  • @DesignsbyBlanc
    @DesignsbyBlanc Месяц назад

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

  • @marcoscabrinirianidosreis6655
    @marcoscabrinirianidosreis6655 23 дня назад

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

  • @GUYX10
    @GUYX10 Месяц назад +1

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

  • @tylerwalton7659
    @tylerwalton7659 Месяц назад

    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!

  • @rogue.ganker
    @rogue.ganker 25 дней назад

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

  • @hellcat8886
    @hellcat8886 Месяц назад +2

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

  • @kushyzee
    @kushyzee 14 дней назад

    You just got yourself a new subscriber! I actually watched a video about all these a few days ago and I kinda understood how it all works but this video is the icing on the cake, I now perfectly understand how it all works and it's all thanks to the beautiful visualizations you used and your straightforward explanation. This video is a goldmine ✅

  • @swayze_0
    @swayze_0 21 день назад

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

  • @eleazerugwu100
    @eleazerugwu100 7 дней назад

    You are an amazing tutor. The visualization is incredible.

  • @erick2051
    @erick2051 Месяц назад

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

  • @phantom7132
    @phantom7132 12 дней назад

    The best visualisation of the JS runtime I've ever seen! Respect Lydia!

  • @souravmitra6370
    @souravmitra6370 23 дня назад

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

  • @simplehacker_
    @simplehacker_ Месяц назад

    These videos are extremely well presented!

  • @chensu4732
    @chensu4732 18 дней назад

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

  • @ajassharafudeen
    @ajassharafudeen 14 дней назад

    4 months ago, I learned event loop from your dev.to post titled JavaScript Visualized: Event Loop - which is the best visualised minimalistic explanation I have come across, and then to refresh it, I watched this video you recently posted.
    Thank you Lydia Hallie.

  • @flnnx
    @flnnx 2 месяца назад

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

  • @DontFollowZim
    @DontFollowZim Месяц назад

    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...

  • @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.

  • @RohitDubeyJLSARP
    @RohitDubeyJLSARP Месяц назад

    One of the best video ever that explains concepts this clear. 🙌

  • @nelsonelijah5327
    @nelsonelijah5327 Месяц назад

    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!

  • @jordachmakaya493
    @jordachmakaya493 14 дней назад

    Ridiculously simple when you explain it. You just got new subscriber !

  • @jijuntang509
    @jijuntang509 3 дня назад

    So great! I love this kind of explanation with animations! It makes complicated concepts so much easier to understand! Thank you very much for the video!

  • @geoffreymoluba7448
    @geoffreymoluba7448 Месяц назад +1

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

  • @thepassionatecoder5404
    @thepassionatecoder5404 Месяц назад

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

  • @jjysoserious
    @jjysoserious Месяц назад

    Best video ive seen on this subject. The visuals help a lot!

  • @gabriellinassi3382
    @gabriellinassi3382 2 месяца назад

    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

  • @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.

  • @SanketBhat7
    @SanketBhat7 Месяц назад

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

  • @aGoodOmen
    @aGoodOmen 2 месяца назад

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

  • @sebas_xs
    @sebas_xs 2 месяца назад +1

    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!

  • @phannguyetnguyen8254
    @phannguyetnguyen8254 2 дня назад

    I've been dreaming of one day creating such video for years. I'm happy seeing someone did it beautifully, especially when it is a soft spoken girl.

  • @suenkaiching1580
    @suenkaiching1580 2 месяца назад

    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!!

  • @me_rinta
    @me_rinta Месяц назад

    Best event look explanation video I’ve seen
    Awesome work! ❤

  • @vikramtatke5930
    @vikramtatke5930 2 месяца назад

    This is absolute gold! So glad RUclips 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!

  • @warta312
    @warta312 Месяц назад

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

  • @teamgartz-motorsports6881
    @teamgartz-motorsports6881 17 дней назад

    Your presentation is absolute the best event loop explanation I ever saw. Thank you and congratulations in doing such amazing work to help other people.

  • @ievgeniibielkin
    @ievgeniibielkin 4 дня назад

    Thank you so much for presenting this topic, Lydia.

  • @WebQrious
    @WebQrious Месяц назад

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

  • @dopetag
    @dopetag Месяц назад

    The best explanation and visualisation! Kudos!
    Instant subscription!

  • @meetfilipe_
    @meetfilipe_ Месяц назад

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

  • @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!

  • @lceda
    @lceda 16 дней назад

    That's a really good way to explain something which can be complex trying to understand it without the visualization! Thanks alot for sharing this gold content!

  • @noozytechz
    @noozytechz Месяц назад

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

  • @Mar444_
    @Mar444_ 11 дней назад

    This is brilliant! Such clarity💎😄Thank You!

  • @Mossy45
    @Mossy45 11 дней назад

    This has saved my sanity on something I thought I could never understand.

  • @IceBreakerGamer
    @IceBreakerGamer Месяц назад

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

  • @marianopainefil3537
    @marianopainefil3537 Месяц назад

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

  • @ShredNekM80
    @ShredNekM80 Месяц назад

    The presentation and clarity of this information is excellent! Thank you for making this video. It made understanding the Event Loop so much easier!

  • @jtnovellis
    @jtnovellis Месяц назад

    This is the best video that I have watched about how works the event loop

  • @Abdullahalmamun-bf5tc
    @Abdullahalmamun-bf5tc Месяц назад

    It is one of the best explanation that i ever had

  • @hosampb5593
    @hosampb5593 18 дней назад

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

  • @ryanmalesic8385
    @ryanmalesic8385 Месяц назад

    This is the best video on this topic I’ve ever seen. And I’ve seen many

  • @_nsikak
    @_nsikak 26 дней назад

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

  • @kamhawy
    @kamhawy 22 дня назад

    Well explained with smooth & meaningful animation.
    Awesome 👏👍

  • @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.

  • @AntonioLettieri
    @AntonioLettieri 2 месяца назад

    Best example of a task queue I have seen in a very long time.

  • @glyakk
    @glyakk Месяц назад

    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.

  • @danielwilkowski5899
    @danielwilkowski5899 Месяц назад +2

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

  • @davidpaez_co
    @davidpaez_co Месяц назад

    This video deserves 10M views. Incredible work Lydia!

  • @ilonakhomenko3797
    @ilonakhomenko3797 2 месяца назад

    This video is absolutely amazing! Very clear and straight to the point. I often struggle with understanding JS, and I found this video incredibly helpful. Thanks, Lydia! Looking forward for your new videos 👍

  • @artless-soul
    @artless-soul Месяц назад

    Thank you for all the efforts with the graphics!.. very well explained!! 👍👍

  • @JoysterRodrigues7
    @JoysterRodrigues7 2 месяца назад

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

  • @TheZenJin
    @TheZenJin Месяц назад

    Just wow! This is pants down the best Tutorial-Style-Vid I have ever seen. Please keep it up, I love it!

  • @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