Tock.js
JavaScript driftless timer
JavaScript driftless timer.
If you use setTimeout with a time of, say, 1000ms and assume that each tick will happen after 1000ms, you’re going to have a bad time.
So I wrote a little library that will compensate for this drift and continue to tick at roughly the time you want. Not perfect but it shouldn’t drift further and further away from the ideal.
I made this several years ago and JacaScript has introduced better APIs for this sort of thing, so I wouldn’t recommend using it anymore.