Earlier quoted context omitted.
Agree, I wish every project would have that! I still think the conclusion on "setTimeout is cursed"[0] is faulty: > The setTimeout method in JavaScript is cursed when used with small values because the implementation may or may not actually wait the specified time. The issue to me seems that performance.now() [1] returns the timestamp in milliseconds and will therefor round up/down. So 1ms errors are just within its…
JS is not a realtime language. setTimeout() does not actually guarantee to run after the elapsed time. It merely gets queued for the next async execution window after that timer elapsed. Hence it can also be off by infinity and never get called - because JS is single threaded (unless you use a worker - which comes with its own challenges) and async windows only open if the main thread is "idle". Usually, this is very…
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/setT...