β οΈ RequestAnimationFrame instead of setTimeout or setInterval
#js #requestAnimationFrame
β Link: https://javascript.plainenglish.io/speed-up-your-javascript-proven-techniques-for-optimizing-performance-c3471f8df54f
#js #requestAnimationFrame
β Link: https://javascript.plainenglish.io/speed-up-your-javascript-proven-techniques-for-optimizing-performance-c3471f8df54f
π1
#settimeout #setinterval #event_loop #requestAnimationFrame
Why setTimeout is Inaccurate? β
setTimeout and setInterval in JavaScript are based on the event loop and task queue. Their execution time may vary due to several factors:
Event Loop Mechanism:
JavaScript executes code within a single event loop. If earlier tasks take a long time or the task queue is busy, the timer callback will be delayed.
Task Queue Priority:
The priority of tasks in the task queue varies. User interaction events or rendering updates might have higher priority than setTimeout and setInterval, delaying their execution.
JavaScript Engine Limitations:
The JS engine normally imposes a minimum delay; for example, nested setTimeout calls usually have a minimum delay of 4 milliseconds.
System Performance and Load:
System performance and current load can also affect timer accuracy. High system load can further delay task execution.
β Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
#js #workers #debounce #srcset #requestAnimationFrame #IntersectionObserver
β Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
β€1
#js #performance #throttle #debounce #requestAnimationFrame #workers
β Article Link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5