- If you enjoy this project, please ⭐ it on{' '} - - GitHub - - ! -
-Event Loop
-- A call stack is a mechanism for an interpreter to keep track of its - place in a script that calls multiple functions — what function is - currently being run and what functions are called from within that - function, etc. -
-- The event loop is a fundamental concept in browser that manages the - execution of code, handling of events, and updating of the user - interface. -
-- The event loop continuously checks for and processes events and queued - tasks in a specific order: -
-- A microtask is a short function which is executed after the function - or program which created it exits and only if the JavaScript execution - stack is empty, but before returning control to the event loop being - used by the user agent to drive the script's execution environment. -
-Events that can trigger new microtasks:
-- The window.requestAnimationFrame() method tells the browser you wish - to perform an animation. It requests the browser to call a - user-supplied callback function before the next repaint. -
-- The frequency of calls to the callback function will generally match - the display refresh rate. The most common refresh rate is 60hz, (60 - cycles/frames per second), though 75hz, 120hz, and 144hz are also - widely used. -
-- requestAnimationFrame() calls are paused in most browsers when running - in background tabs or hidden iframes, in order to improve performance - and battery life. -
-- A task is anything which is scheduled to be run by the standard - mechanisms such as initially starting to run a program, an event being - dispatched asynchronously, or an interval or timeout being fired. - These all get scheduled on the task queue. -
-- For example, tasks get added to the task queue when: -
-