Yes. setTimeout
accuracy is based on many factors and is not guaranteed to be always executed at the time you specify.
I can’t say this with any authority, but I’ll be afraid that Firefox, trying to seem faster, will temporarily speed up the JS engine so that everything is in motion (which is interesting because, in my experience, timer-based functions actually running slower first in my version of firefox).
Neither setTimeout
nor setInterval
promise that they will be executed at the exact time, as indicated in the link you provided. However, with setInterval
you get the advantage of a timer loop doing everything possible to “fix itself”, catching up if it lags too far, so whatever you try to do, it might be more appropriate.
Anyway, here are my results on my Macbook 10.6.8:
Firefox 5.0.1:
waited 92 waited 92 waited 93 waited 93 waited 93 waited 93 waited 93 waited 94 waited 93 waited 93 waited 93 waited 93 waited 94 waited 94 waited 94 waited 94 waited 94 waited 95 waited 96 waited 96
Safari 5.1.5:
waited 100 waited 104 waited 104 waited 103 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104
Chrome 19.0.1084.52:
waited 101 waited 103 waited 103 waited 104 waited 104 waited 103 waited 103 waited 103 waited 103 waited 103 waited 103 waited 103 waited 103 waited 103 waited 104 waited 104 waited 104 waited 104 waited 104 waited 104
source share