Skip to content Skip to sidebar Skip to footer

Javascript Setinterval Execution In Less Than 1 Ms?

I have this example that compares the performance of a simple counter loop using for loop and using setInerval, the exeuction time difference is huge as follows: var i = 0; var i2

Solution 1:

setInterval and setTimeout are forced to use at least the minimum delay. The minimum delay, DOM_MIN_TIMEOUT_VALUE, is 4 ms which is specified by the HTML5 spec and is consistent across browsers released in 2010 and onward.

In modern browsers you can use window.postMessage() as a workaround to implement a 0 ms timeout as described here.

Post a Comment for "Javascript Setinterval Execution In Less Than 1 Ms?"