Skip to main content

Async and Performance

15th October, 2022

Updated: 15th October, 2022

    What if there are already 20 items in the event loop at that moment? Your callback waits. It gets in line behind the others -- there's not normally a path for preempting the queue and skipping ahead in line. This explains why setTimeout(..) timers may not fire with perfect temporal accuracy. You're guaranteed (roughly speaking) that your callback won't fire /before/ the time interval you specify, but it can happen at or after that time, depending on the state of the event queue.


    882d10e7-77ee-49a4-8095-43e92bfba72c

    Created on: 15th October, 2022

    Last updated: 15th October, 2022

    Source: https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/async%20%26%20performance/ch1.md

    Tagged With: