setZeroTimeout is a simple utility function allowing you to use a sub-10ms (near-instantaneous, in most cases) asynchronous setTimeout analogue. This is performed using the browser's messaging system. In simpler terms: 0ms setTimeout.
Its usage is simple:
It uses setTimeout syntax, because in unsupporting browsers (FF<3, IE<8, SF<5, O<10),
setZeroTimeout is actually a reference to
setTimeout. Therefore, the second parameter of timeout is mandatory. On most old browsers, the actual minimum for setTimeout is ~10ms. setZeroTimeout usually runs much under 1ms.
While other setZeroTimeout implementations exist, this particular one continues to throw valid
Licensed freely under CC 3.0: http://creativecommons.org/licenses/by/3.0/