Angular ๐Ÿ‡บ๐Ÿ‡ฆ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
๐Ÿ“ต Optimizing JavaScriptโ€™s Event Loop

#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