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

Sdílet
Vložit
  • čas přidán 1. 06. 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

Komentáře • 1K

  • @theavocoder
    @theavocoder  Před měsícem +164

    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 Před měsícem +4

      Gotta love you for respecting our time.

    • @swaminathbera6407
      @swaminathbera6407 Před měsícem

      From where did you learn?

    • @sourabhjana1278
      @sourabhjana1278 Před měsícem +2

      Can you please extend this more to explain NodeJS runtime 🙏

    • @inowatchvideos
      @inowatchvideos Před měsícem +2

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

    • @joshuafontiveros7877
      @joshuafontiveros7877 Před měsícem

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

  • @bilalarain4632
    @bilalarain4632 Před měsícem +271

    i think thousands of senior developers finally understood it today.

    • @DasBeatz
      @DasBeatz Před 27 dny

      🤯

    • @scryptum
      @scryptum Před 24 dny +2

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

    • @KAIDO-mi1tr
      @KAIDO-mi1tr Před 24 dny +2

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

    • @bilalarain4632
      @bilalarain4632 Před 24 dny

      @@KAIDO-mi1tr haha

    • @yangliu2713
      @yangliu2713 Před 16 dny

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

  • @carltongordon
    @carltongordon Před měsícem +523

    Where has this channel been all my life?

    • @pawanpulami6091
      @pawanpulami6091 Před měsícem +2

      Exactly I was thinking the same 😂

    • @peacemurder3778
      @peacemurder3778 Před měsícem +8

      In the future obviously. 😂

    • @riccardoguitar
      @riccardoguitar Před měsícem +9

      She already done a longer vid for freeCodeCamp 2 years ago and she's on FrontedMasters as Teacher
      czcams.com/video/xckH5s3UuX4/video.html

    • @theblackelephant
      @theblackelephant Před měsícem +1

      Same here❤❤❤❤❤

    • @pubudusenarathne
      @pubudusenarathne Před měsícem

      Exactly!!

  • @ryandawson1220
    @ryandawson1220 Před měsícem +239

    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 Před 16 dny +18

    This video should receive the Oscar for best animation

  • @jamesallen74
    @jamesallen74 Před měsícem +268

    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 Před měsícem

      9 years ago was this video... her video seems a rip-off
      czcams.com/video/8aGhZQkoFbQ/video.html&ab_channel=JSConf

    • @TheNomadsTimeCapsule
      @TheNomadsTimeCapsule Před měsícem +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 Před měsícem +1

      ditto

  • @Ainigma
    @Ainigma Před měsícem +63

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

  • @timurdinov7452
    @timurdinov7452 Před 16 dny +17

    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 Před 13 dny +2

      Thank you. Absolutely wondered this.

    • @akashrajum3319
      @akashrajum3319 Před 5 dny

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

  • @phantom7132
    @phantom7132 Před 7 hodinami

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

  • @amulpatel
    @amulpatel Před měsícem +26

    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 Před měsícem +37

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

  • @ajassharafudeen
    @ajassharafudeen Před 2 dny

    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.

  • @ahmedmaaz4390
    @ahmedmaaz4390 Před měsícem +4

    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 Před měsícem +15

    This is the type of visualization that coding vids need

    • @AndrewTSq
      @AndrewTSq Před měsícem

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

  • @huycaoviet8367
    @huycaoviet8367 Před měsícem +65

    I finally understand Event Loop after 1 year writing JS.

    • @ericjeker
      @ericjeker Před měsícem +18

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

    • @jonniem
      @jonniem Před měsícem +4

      I thought I did… until today😅

    • @lamhung4899
      @lamhung4899 Před měsícem +2

      No you do not 😂

    • @chess4964
      @chess4964 Před měsícem +1

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

    • @dbzfan2487
      @dbzfan2487 Před 19 dny

      Then you're a shit developer tbh

  • @jordachmakaya493
    @jordachmakaya493 Před dnem

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

  • @teamgartz-motorsports6881

    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.

  • @TC14
    @TC14 Před měsícem +23

    Top tier presentation, this is easily one of the best visualizations I've seen on CZcams. 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 Před měsícem +5

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

  • @someshkarmakar47
    @someshkarmakar47 Před 9 dny

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

  • @tomjerry0796
    @tomjerry0796 Před 14 dny +1

    12 min just recalled my last 2 years ❤🎉

  • @slevinstayshere
    @slevinstayshere Před měsícem +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!

  • @Isaac-hd6vs
    @Isaac-hd6vs Před měsícem +3

    Hands down, the best event loop explanation ever!

  • @paulobelucci
    @paulobelucci Před 12 dny

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

  • @lceda
    @lceda Před 4 dny

    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!

  • @HamzaKhan-rs2yo
    @HamzaKhan-rs2yo Před měsícem +5

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

  • @CrusaderMen
    @CrusaderMen Před měsícem +22

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

  • @paulopontovaz
    @paulopontovaz Před měsícem +1

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

  • @zanfet
    @zanfet Před 16 dny

    Amazing visual explanation! Thank you!

  • @leepaulison4928
    @leepaulison4928 Před měsícem +4

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

  • @MagnumCarta
    @MagnumCarta Před měsícem +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.

  • @swayze_0
    @swayze_0 Před 8 dny

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

  • @monilcharola6873
    @monilcharola6873 Před 3 dny

    New Knowledge Gold Mine ALERT!!!!!!!!!!!
    Fantastic work Lydia, thank you so much for this video. I'll be one of your subscriber for the entire of your youtube journey.
    Keep teaching using such mind blowing visuals which are sooo helpful in understanding the concepts.
    Thanks you again.

  • @jackwright517
    @jackwright517 Před měsícem +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! 💯

  • @forkanshanto2228
    @forkanshanto2228 Před měsícem +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.

  • @vapon
    @vapon Před 13 dny +1

    Just jamming here... being C++ developer for 30 years, reading all these comments about seniors and juniors...I wonder: Guys have you ever read a text book about your profession?
    Nice video btw!

    • @patilmayurn
      @patilmayurn Před 3 dny

      The world cheers for splashy things and call themselves a "coder" and then cry that AI will take the job. The traditional way is long gone where we used to read the books, make our own interpretation and test our understanding by hands-on coding.
      But, a good explanation in the video. no doubt.

  • @GUYX10
    @GUYX10 Před měsícem +1

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

  • @mattpocockuk
    @mattpocockuk Před měsícem +13

    Fucking hell Lydia, this is incredible

  • @souravmitra6370
    @souravmitra6370 Před 10 dny

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

  • @sagardeka2158
    @sagardeka2158 Před měsícem

    very clean and beautiful presentation

  • @PostMeridianLyf
    @PostMeridianLyf Před měsícem +12

    Are you Ai? This seems too perfect

    • @The_Wookiee
      @The_Wookiee Před měsícem +1

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

  • @abdulrahmantahir3033
    @abdulrahmantahir3033 Před měsícem +8

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

  • @simplehacker_
    @simplehacker_ Před 28 dny

    These videos are extremely well presented!

  • @AaronAsherRandall
    @AaronAsherRandall Před 8 dny

    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.

  • @chensu4732
    @chensu4732 Před 5 dny

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

  • @marcoscabrinirianidosreis6655

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

  • @kushyzee
    @kushyzee Před 2 dny

    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 ✅

  • @RemigiuszDudek
    @RemigiuszDudek Před měsícem

    beautiful and simple, Lydia great work. Thank you!

  • @_nsikak
    @_nsikak Před 13 dny

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

  • @flnnx
    @flnnx Před měsícem

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

  • @Cangussu97
    @Cangussu97 Před měsícem

    Absolutely incredible explanation and visualisation. Thank you!!

  • @DesignsbyBlanc
    @DesignsbyBlanc Před měsícem

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

  • @noozytechz
    @noozytechz Před měsícem

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

  • @basilenordmann7356
    @basilenordmann7356 Před 14 dny

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

  • @SaiPrakash16
    @SaiPrakash16 Před měsícem +2

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

  • @juanpabloalvaradovallejo5770

    I really loved this video!! Amazing explanation! Thanks!!

  • @aGoodOmen
    @aGoodOmen Před měsícem

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

  • @TheDogn
    @TheDogn Před měsícem

    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.

  • @MansoorAhmad-dg3sk
    @MansoorAhmad-dg3sk Před 13 dny

    This crazy visualisation 🔥
    Super easy, super fun 😮

  • @RohitDubeyJLSARP
    @RohitDubeyJLSARP Před 17 dny

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

  • @jjysoserious
    @jjysoserious Před měsícem

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

  • @StarDoesntUpload
    @StarDoesntUpload Před 29 dny

    Excellent visual explanation

  • @arthurvmdantas
    @arthurvmdantas Před 19 dny

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

  • @tylerwalton7659
    @tylerwalton7659 Před 17 dny

    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!

  • @junior.santana
    @junior.santana Před 12 dny

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

  • @SanketBhat7
    @SanketBhat7 Před měsícem

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

  • @artless-soul
    @artless-soul Před 19 dny

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

  • @me_rinta
    @me_rinta Před měsícem

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

  • @minalahuja2846
    @minalahuja2846 Před 14 dny

    Amazing explanation! Thanks for sharing this.

  • @kamhawy
    @kamhawy Před 9 dny

    Well explained with smooth & meaningful animation.
    Awesome 👏👍

  • @IceBreakerGamer
    @IceBreakerGamer Před 23 dny

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

  • @zackanderson6084
    @zackanderson6084 Před měsícem

    Amazing explanations, and I love the reiterative approach of the ideas and concepts!!

  • @itsjmendez
    @itsjmendez Před 17 dny

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

  • @Software..Engineer
    @Software..Engineer Před měsícem +1

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

  • @kstanyslaw
    @kstanyslaw Před 18 dny

    Awesome explanation! Thank you!😊

  • @suenkaiching1580
    @suenkaiching1580 Před měsícem

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

  • @ashuvssut
    @ashuvssut Před měsícem

    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

  • @dopetag
    @dopetag Před měsícem

    The best explanation and visualisation! Kudos!
    Instant subscription!

  • @adamcarroll3498
    @adamcarroll3498 Před 13 dny

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

  • @mdamiruddin896
    @mdamiruddin896 Před 10 dny

    Thanks! A well put together explanation.

  • @erick2051
    @erick2051 Před 24 dny

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

  • @hellcat8886
    @hellcat8886 Před měsícem +2

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

  • @rea_kr
    @rea_kr Před měsícem

    이런 시각화 자료를 통해서 공부를 하게 되니 이해가 쉽게 됩니다. 감사합니다.

  • @misaellopes01
    @misaellopes01 Před 24 dny

    Simply Amazing, this content is gold 🙌!!!

  • @EbrahimTahernejad
    @EbrahimTahernejad Před měsícem

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

  • @ylaguardia
    @ylaguardia Před měsícem

    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!

  • @victorv7364
    @victorv7364 Před 29 dny

    The explanation is awesome, thank you

  • @glimpsee7941
    @glimpsee7941 Před 8 dny

    Absolutely fantastic video

  • @rjwhite4424
    @rjwhite4424 Před 19 dny +1

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

  • @fadichamieh
    @fadichamieh Před měsícem

    Simply Great illustration of a seemingly simple yet inherently complex topic: JavaScript tasks and async / promise execution

  • @TheAsjath
    @TheAsjath Před měsícem

    This is simply amazing 🤩. Learned a lot today

  • @warta312
    @warta312 Před 27 dny

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

  • @viatrixhd
    @viatrixhd Před měsícem

    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

  • @teleprint-me
    @teleprint-me Před měsícem

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

  • @ShredNekM80
    @ShredNekM80 Před měsícem

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

  • @WebQrious
    @WebQrious Před 17 dny

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

  • @shashankmarri1056
    @shashankmarri1056 Před dnem

    Magnificent Video...!!! I will share this video to all my Front End developers and my junior developers. It will give them a clear understanding of events and callbacks. Im convinced to subscribe to your channel.

  • @nemethricsi
    @nemethricsi Před měsícem

    Lydia, this is the best explanation I’ve ever heard about this topic ❤ thank you!

  • @AlimamiHD
    @AlimamiHD Před měsícem

    Bro you are amazingly explaining. Like the animation.

  • @JoysterRodrigues7
    @JoysterRodrigues7 Před měsícem

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