Jake Archibald on the web browser event loop, setTimeout, micro tasks, requestAnimationFrame, ...

Поделиться
HTML-код
  • Опубликовано: 27 сен 2024
  • "In The Loop" presented by Jake Archibald at JSConf.Asia 2018
    Have you ever had a bug where things were happening in the wrong order, or particular style changes were being ignored? Ever fixed that bug by wrapping a section of code in a setTimeout? Ever found that fix to be unreliable, and played around with the timeout number until it kinda almost always worked?
    This talk looks at the browser's event loop, the thing that orchestrates the main thread of the browser, which includes JavaScript, events, and rendering. We'll look at the difference between tasks, microtasks, requestAnimationFrame, requestIdleCallback, and where events land.
    Hopefully you'll never have to use setTimeout hacks again!"
    Jake is developer advocate for Google Chrome. He's one of the editors of the service worker spec, so he's into offline-first, push messaging and web performance.
    JSConf.Asia - Capitol Theatre, Singapore - 27 January 2018
    Source: 2018.jsconf.asia/
    License: For reuse of this video under a more permissive license please get in touch with us. The speakers retain the copyright for their performances.

Комментарии • 533

  • @The9TKitsune
    @The9TKitsune 5 лет назад +2505

    When you want to be a stand up comedian and life makes you a JS expert

    • @eritreanism
      @eritreanism 5 лет назад +16

      on point :)

    • @oleksii208
      @oleksii208 5 лет назад +7

      hahahahah

    • @markmhaslam
      @markmhaslam 4 года назад +62

      Seriously! He's super funny. I would honestly love to watch him do stand-up.

    • @LethiuxX
      @LethiuxX 4 года назад +39

      Comedy is his hobby, it seems.

    • @perfect.stealth
      @perfect.stealth 3 года назад +2

      Lmao

  • @buddhaburrito
    @buddhaburrito 3 года назад +296

    Jake is a truly genius presenter, sliding in jokes in between heavy subjects (like microtasks) so that audience can take mental rests

  • @Nyromancer
    @Nyromancer 6 лет назад +1030

    Humour is his hobby I guess. At least I find him funny, tough crowd...

    • @jakearchibald
      @jakearchibald 6 лет назад +129

      In standup gigs they mic the audience too. They were more alive than the video suggests (but still pretty quiet)

    • @JAlexanderCurtis
      @JAlexanderCurtis 5 лет назад +24

      Yeah I actually found his jokes to be pretty funny. I at least chuckled at most of them. My guess is the audience might have been giggling and chuckling too, but the laughter wasn't picked up by his lav mic. At 18:30 when he talks about the fizzy water, it's dead silent, but the way he rifted on it for a second indicates that he was probably getting a decent response from the audience.

    • @Litonfiredesign
      @Litonfiredesign 5 лет назад +5

      @@JAlexanderCurtis Thats him that you responded too ;-) Great work on the presentation @jake quality. Thanks for your efforts.

    • @utsavprabhakar5072
      @utsavprabhakar5072 5 лет назад +5

      @@jakearchibald Thanks for this !

    • @erikachurchman9417
      @erikachurchman9417 5 лет назад

      wow

  • @SamiullahKhan
    @SamiullahKhan 6 лет назад +129

    He really hit the core of the event loop. Something that is so important to get hold of tasks, micro tasks.

  • @atticoos
    @atticoos 6 лет назад +210

    Hot damn, Jake.. this is one of the best talks I've seen. Well done.

  • @vishnusingh4118
    @vishnusingh4118 4 года назад +158

    7:08 Task Queues
    8:55 render steps
    12:15 hence the timeOut loop is not 'render blocking'.
    12:29 but if you want to run code that has anything to do with rendering, a task is the wrong place to do it, coz it's on the 'opposite' side of the world from rendering, as far as the event loop is concerned.
    24:00 MicroTasks (RAF - RequestAnimationFrame finishes here )

  • @LichardD
    @LichardD 5 лет назад +77

    Came here to learn about event loops.
    I now fear those who drink fizzy water.

  • @maximlyakhov967
    @maximlyakhov967 2 года назад +38

    This is the best event loop talk on YT.
    Well balanced mental load / mental rest.
    Thank you, Jake!

  • @apifiddle
    @apifiddle 4 года назад +117

    Jake is an amazing asset for the JS community!

    • @codeaperture
      @codeaperture 3 года назад +1

      I always watch this when I feel " you don't know JavaScript yet,,"

  • @anonwithamnesia
    @anonwithamnesia 5 лет назад +2408

    Who is here because of Fireship?

  • @denis.klyuev
    @denis.klyuev 12 дней назад

    I was today years old when I found out how event loop actually works. Thanks a lot, Jake! Wish you many years of health!

  • @ashishshubham
    @ashishshubham 5 лет назад +86

    I wish I learnt all my CS courses from you Jake.

  • @mattscheurich1037
    @mattscheurich1037 5 лет назад +9

    Super great explainer, whoever did the design for the animations deserves a massive shout-out. Well thought out and great visual metaphors too.

    • @jakearchibald
      @jakearchibald 5 лет назад +23

      I do all my own stunts

    • @rizaldywirawan
      @rizaldywirawan 5 лет назад +1

      ​@@jakearchibald Full Stack Speaker, i guess :v ... Can you tell us what software do you use or how you create the animation, please?

    • @mreyybree
      @mreyybree 5 лет назад +1

      @@rizaldywirawan He uses HTML+CSS+JS+SVG

  • @bg_x6558
    @bg_x6558 6 лет назад +112

    This talk is soooo informative. A single effective visual plus narrative beats a thousand words.
    Could someone enlighten me of the tool or the way for the speaker to make the slides (or something else) ?

    • @DheerajBhaskar
      @DheerajBhaskar 5 лет назад +11

      I'm also interested. I think he used HTML5 and js to make this

    • @ys5399
      @ys5399 5 лет назад +3

      I think I know you from Columbus Ohio??

  • @jlyunior
    @jlyunior 3 года назад +2

    This talk has to be displayed in the best Cinemas :) amazing talk 3 years later and im totally sure that will be a good talk to watch again in 2035

  • @maximofernandez196
    @maximofernandez196 2 года назад

    "You don't want to write a code that is like a sneeze". Yeah, this is probably one of the best talks I've ever seen, actually pedagogical if we think about it

  • @kieran2347
    @kieran2347 3 года назад +8

    Thank you for explaining event loops for all of us 5-year-olds, Jake! You the best!

  • @markovujanic
    @markovujanic 2 года назад +1

    This video sits much better after third time 'through the loop'. Thanks Jake for creating it.

  • @SocksWithSandals
    @SocksWithSandals 5 лет назад +2

    I was that guy who would throw in a setTimeout and play around with the delay number until the manual test matched the automated test.
    It would raise an eyebrow at code reviews, but I'm a pragmatist not a purist.
    Now I know why I was right! Thanks Jake.

  • @faceupanddown
    @faceupanddown 5 лет назад +7

    You can have a new hobby at which you are extremely good and it's technical presentations about JS and web.
    Aaaa, also, the how different queues are processed made shivers run up my neck. Really excited. Wife (who is senior QA) is getting jealous of you :p

  • @justinhalsall4077
    @justinhalsall4077 6 лет назад +7

    Love Jake's talks, always super solid, informative and even include some giggles from time to time!

  • @indylawi5021
    @indylawi5021 5 лет назад +11

    Great, fun to watch, very intuitive (with a good sense of humor) presentation for a deep insight into what is going on inside the JS event loop. Jake, you definitely nail JS event loop.

  • @AmandeepSingh-hd8iq
    @AmandeepSingh-hd8iq 5 лет назад +6

    Now this is what you call a talk. Impeccable 👌

  • @dacao9240
    @dacao9240 2 года назад

    I want to download this video and save it in my laptop, just in case youtube goes down. That's how much I love this video.

  • @c9988774455
    @c9988774455 6 лет назад +13

    I never Heard about Microtasks even though I am using Promises, Great visual comparison between JSTasks, rAF and Microtasks. Awesome stuff Jake.

  • @Pupu._
    @Pupu._ 2 года назад +4

    great video! I might need to watch again to wrap up the concepts but he's a great speaker with fun ! I hope he gives us more talks like this

  • @ashokethapay
    @ashokethapay Год назад

    What an amazing talk. It cleared out lot of my queries around the event loop, when the browser prepares a frame, and how much javascript it runs before the frame. Thanks, Jake!!!

  • @shenoynishant
    @shenoynishant 5 лет назад +14

    This is awesome! I had developed a parallax feature using rAF, and I was wondering why it was smooth on Chrome but janky on Edge, this explains it :)

  • @Ashok-wc9be
    @Ashok-wc9be 4 года назад +3

    This guy is super awesome and this talk is probably the best talk on the event-loop out there! Thanks a lot!

  • @sgwatyt
    @sgwatyt 6 лет назад +200

    The main Fred.

  • @MajorBreakfast
    @MajorBreakfast 6 лет назад +36

    Thank you for including the part about microtasks! Very informative!

  • @AhmadAwais
    @AhmadAwais 6 лет назад +18

    Just like always, amazing presentation, especially when you magically swapped those lines around at 2:25 😲

  • @stackdeveloper6614
    @stackdeveloper6614 9 месяцев назад

    My life as a developer changed after this talk!

  • @xerxius5446
    @xerxius5446 5 лет назад +11

    Finally, a JS expert with a sense of humor !

  • @paavangupta3420
    @paavangupta3420 2 года назад

    His way of explaining things with so much clarity and hilarious jokes in between, is on the next level 😂🙌 Amazing!

  • @dnav10
    @dnav10 5 лет назад +5

    Didn't know anything about this. Now I feel like wanting to dig more into JavaScript

  • @smitthakkar9837
    @smitthakkar9837 Год назад +1

    One of the best talks till date on event loop! Thanks a lot!

  • @NorthEagle
    @NorthEagle 5 лет назад +2

    Why the F isn't this video watched 1 million times? This is amazingly informative and presented in a really really good way :-)

  • @johnlennon407
    @johnlennon407 10 месяцев назад

    Wow, what a fantastic performance! Entertaining and informative, with deep philosophical thoughts like sneezing metaphor or orbits and sun animations. The lector is brilliant.

  • @afca25
    @afca25 2 года назад

    That's a tough crowd if i've ever seen one... My man is killing it there!!

  • @anirudhsreerambhatla6108
    @anirudhsreerambhatla6108 5 лет назад

    This is one of the best talks I have seen after Phillips Roberts What the heck is the event loop? Both these talks helped me understand the Event Loop and get better context
    I then took the JS the Hard Parts from Front End Masters by Will Sentence. It was great. I got a better understanding of the the async and concurrency model of JS

    • @kf88743
      @kf88743 5 лет назад

      I have followed the same path, except in reverse. I came here after watching all of Will Sentence's videos on Front End Masters. He is by far my favorite instructor there.

  • @shivam.mishra
    @shivam.mishra 4 года назад +1

    Never had such a clear vision of the event loop. Thanks jake

  • @christiansmitherman
    @christiansmitherman 2 года назад +4

    Who else was sent here by Fireship??

  • @yonoseespanol
    @yonoseespanol 3 года назад +2

    For those who find this incredibly interesting, Jake and Surma have a talk show called HTTP 203

  • @xingyuye0313
    @xingyuye0313 2 года назад

    This is the best talk on the "event loop" I've ever seen!

  • @ananthakrishnanj729
    @ananthakrishnanj729 5 лет назад +2

    Most informative and engaging talks on event loops! Kudos Jakes.

  • @matanmizrahi2257
    @matanmizrahi2257 5 лет назад

    Best event loop explanation I've ever seen. Microtasks are not getting enough attention these days, and this guys just makes it look so simple

  • @ShahriarAnwar
    @ShahriarAnwar 6 лет назад +26

    Just AWESOME. Jake you're my man.

  • @Textras
    @Textras 6 лет назад +6

    Superb talk Jake. As always!! Now time for a lime soda water.

  • @afca25
    @afca25 2 года назад

    That piano bit was straight up Larry David-esque humor and I loved it!

  • @s3340985
    @s3340985 3 года назад +4

    Great humor, tough crowd :) But honestly, very informative, thank you!

  • @mweb7344
    @mweb7344 3 года назад +2

    that looks and sounds like a real world Sheldon, Great talk !!

  • @waldemarenns4874
    @waldemarenns4874 3 года назад +1

    A classical Archibald. Great talk!

  • @AgingAeroplanes
    @AgingAeroplanes Год назад +1

    When Jeremy from Peep Show finally gets his act together.

  • @AmnonSadeh
    @AmnonSadeh 2 года назад +1

    5:25 "Are the arguments in the wrong order?"
    No, because 'callback' is mandatory, but 'ms' is optional. This is valid JS: setTimeout(callback);

    • @jakearchibald
      @jakearchibald 2 года назад +2

      True, but the API would be better if ms was not optional, and was the first parameter.

    • @DonaldFranciszekTusk
      @DonaldFranciszekTusk 6 месяцев назад

      @@jakearchibaldWhy?

    • @jakearchibald
      @jakearchibald 6 месяцев назад

      @@DonaldFranciszekTusk What's the benefit of ms being optional?

  • @shizueigaki702
    @shizueigaki702 9 месяцев назад

    Absolute legend, this man.

  • @nikhilmishra3291
    @nikhilmishra3291 2 года назад

    2:56 definition of subtle joke/ punch delivery

  • @EduardoWeidmanBarijan
    @EduardoWeidmanBarijan 2 года назад

    That was easy to follow even though I get stuck a lot when it comes to frontend programming. Good job.

  • @havenoideawith
    @havenoideawith 6 лет назад +4

    Love the main thread animation.☺️

  • @Gelio1234
    @Gelio1234 6 лет назад +1

    What a great talk! So much useful information presented in a convenient and easy to understand way

  • @PaulShmaul
    @PaulShmaul 3 года назад +1

    Best explanation of event loop, indeed

  • @JulianSloman
    @JulianSloman 6 лет назад +2

    That laughter at the end "back to the studio" :D

  • @xpkareem
    @xpkareem Год назад

    I disagree about fizzy water, but this is a fantastic talk. Thanks!

  • @amanmavai99
    @amanmavai99 10 месяцев назад

    one of the best talks I have ever seen. !!

  • @SafetyLast-_-
    @SafetyLast-_- 2 года назад

    The best explanation of the Event Loop out there 👍

  • @jasonsebring3983
    @jasonsebring3983 5 лет назад +1

    I feel like I just started learning this stuff and I've been doing it for so long. Amazing!

  • @nukebarbarbarian3735
    @nukebarbarbarian3735 Год назад

    This is the best video on event loop so clear!

  • @תומררונן-ר7ל
    @תומררונן-ר7ל 3 года назад

    Amazing video. You make the subject very clear

  • @driziiD
    @driziiD 3 года назад +1

    brilliant talk

  • @sudeep.g
    @sudeep.g 5 лет назад

    One of the best talks I have ever seen!

  • @Lavasea
    @Lavasea 4 года назад

    This was an amazing talk, the visuals really helped produce a mental image of what goes on in the event loop at any given time.

  • @MerrStudio
    @MerrStudio Год назад

    I love this talk, great job

  • @supa1009
    @supa1009 3 года назад +1

    legendary video

  • @HarshSingh-hk8fe
    @HarshSingh-hk8fe 3 года назад

    this is the best explanation of even loops

  • @newtonmunene
    @newtonmunene 5 лет назад +17

    This is such a tough audience, this guy is hilarious to me😂😂😂

    • @rafadydkiemmacha7543
      @rafadydkiemmacha7543 5 лет назад

      Porbably introverts. I’m one myself and I hate it when the audience laughs like horses. It kills any joke for me.

  • @bonehelm
    @bonehelm 3 года назад

    Great talk, but now I realize why JS in the browser is so frustrating to deal with.

  • @PaperBenni
    @PaperBenni 3 года назад +1

    I like how he uses a joycon for the slides

  • @Maxim9575
    @Maxim9575 3 года назад

    If you are watching it in 2021, example with animation square from 1000 to 500 doesn't work, I don't why, but this doesn't work anymore if it of course ever worked, I've not checked it before

  • @saurabhmehta7681
    @saurabhmehta7681 4 года назад

    Great talk! And his level of understanding is inspirational

  • @AngelCodes95
    @AngelCodes95 7 месяцев назад

    so... as a novice self taught dev. My general first understanding of the event loop is that its a way to sort the handling of code to handle the (Fastest and best) line for speed and keep most other stuff on the bench warming up for its time to shine (run).... Yay or nay?

    • @AngelCodes95
      @AngelCodes95 7 месяцев назад

      soda water bit was hilarious btw

  • @shuvenduoffline
    @shuvenduoffline Год назад

    Best explanation you can find

  • @EduardoRFS
    @EduardoRFS 5 лет назад +2

    wow that was really great talk, i did know that microtasks existed but didn't know when it was executed. Also about the difference between .click() and a user click, shouldn't we have a JS way to make it exactly like users click or dispatching an event click works?
    As always your job was amazing, but gosh, it was a bit sad not hearing the crowd

  • @mr_ozio
    @mr_ozio 4 года назад

    My gosh, the only presentation where I had to set playback speed to lower value.

  • @uzma-k8c
    @uzma-k8c Год назад

    this is awesome, really well explained.

  • @ProdbyQ88
    @ProdbyQ88 3 года назад +1

    Great talk

  • @brianliang3010
    @brianliang3010 11 месяцев назад +1

    new to event loop, and wondering does this concept apply to node.js event loop?

  • @SoreBrain
    @SoreBrain 2 года назад

    This was mind blowing

  • @anonimo0486
    @anonimo0486 6 лет назад +11

    I love his accent:
    fing
    fhread
    fhink
    nofing

    • @hobbyturystaSEO
      @hobbyturystaSEO 4 года назад

      sound like pure British between Manchester n London Loop

  • @juremd
    @juremd 4 года назад

    Great explanation, though the description mentions bits about requestIdleCallback which I did not notice.

    • @jakearchibald
      @jakearchibald 4 года назад +2

      Hah, that's because conferences often ask for an abstract before the talk is written. requestIdleCallback isn't that interesting, it just queues a task when it thinks the user is idle.

  • @anand_maurya
    @anand_maurya 4 года назад

    The most wholesome video I saw today.

  • @lipeiye
    @lipeiye 7 месяцев назад

    When I use the 22:15 code to execute, my effect is inconsistent with the video.
    It stopped while moving towards 1000px and stopped at 500px.
    I think this is caused by changing the transform to 'translateX(500px)'; in the second task cycle.
    Is what I said correct?
    ```
    const button = document.getElementById('btn');
    const box = document.getElementById('box');
    button.addEventListener('click',()=>{
    box.style.transform='translateX(1000px)';
    box.style.transition='transform 1s ease-in-out';
    requestAnimationFrame(()=>{
    requestAnimationFrame(()=>{
    box.style.transform='translateX(500px)';
    })
    })
    })
    ```

  • @Han-ve8uh
    @Han-ve8uh 2 года назад

    At 26:32 "we get our mutation observer callback". Where is it? This code block looks exactly the same as code at 25:10 generating 200 events. What's the code change done that defines/uses these mutation observer callbacks?

  • @patrikkolenovsky2788
    @patrikkolenovsky2788 3 года назад +1

    This dude got name like some main boss in diablo

  • @shikharchaudhary6984
    @shikharchaudhary6984 5 лет назад

    Amazing talk. Cleared my concepts. Good Job !

  • @stefanianta6962
    @stefanianta6962 Год назад

    Our Mitochondria loop might work somehow similar except it includes also an gene monetizer / ATP coiner 🙂

  • @Moarmmoforme
    @Moarmmoforme 5 лет назад +1

    His delivery reminds me of Ricky Gervais soooooooo much, except for the cussing and the beer :P

  • @alexcouter
    @alexcouter 4 года назад +1

    Jake makes me think of Moss from IT Crowd.

  • @danieltroger
    @danieltroger Год назад

    This talk was SOOO GOOOd. TYSM 🙏

  • @telzamahel
    @telzamahel 6 месяцев назад +1

    Tough crowd. This guy was hilarious!

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

    11:12 I don't understand... After first doing the "document.body.appendChild(el)" task, why would the event loop not do a page render and THEN do the next task: "el.style.display = 'none'" before rendering again???

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

      Those commands do not queue tasks