Exact Javascript Timeout

/ Published in: JavaScript
Save to your folder(s)

This is a more precise version of the native setTimeout(). It uses the same parameters as setTimeout, but adds a third parameter "resolution" which defines how often (in ms) to check for the time that passed.

// alert after 5 seconds with an inaccuracy of 20 milliseconds
var timeout = setExactTimeout(function(){
}, 5000, 20);

// comment out to show "done"

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.