4 ms·
Any timer is constrained to the resolution set by the system timer. To go lower one would require something akin to a spin-loop, which defeats any gain by keepi
by personalcompute 13y ago
Any timer is constrained to the resolution set by the system timer. To go lower one would require something akin to a spin-loop, which defeats any gain by keeping the resolution high.
- mischanix 13y agosetTimeout(,0) is a special case. It means "make this function be ran after the current call stack clears". That requires neither a timer nor a spin loop.
- pcwalton 13y agoIf browsers did that they would break the Web. They must clamp to some low delay (4 ms, I believe) or else some pages will lock up. See https://bugzilla.mozilla.org/show_bug.cgi?id=123273 https://bugzilla.mozilla.org/show_bug.cgi?id=123273
- deleted 13y ago[deleted]
- mischanix 13y agoRight, but that precedent was only set by incorrect implementations existing in the first place. Using setTimeout(,0) recursively in lieu of (a then unavailable) requestAnimationFrame or a non-zero timeout period is in my mind equivalent to while(true){}/infinite tail recursion.
- mischanix 13y agoAnd yes, in the HTML5 spec (years later), it was standardized to a 4ms clamp, also because of the incorrect implementations prior.
- rimantas 13y agoRelated: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/ http://www.nczonline.net/blog/2013/07/09/the-case-for-setimm...