Is there a more accurate way to create a Javascript timer than setTimeout?

后端 未结 16 2018
礼貌的吻别
礼貌的吻别 2020-11-22 14:11

Something that has always bugged me is how unpredictable the setTimeout() method in Javascript is.

In my experience, the timer is horribly inaccurate in

16条回答
  •  粉色の甜心
    2020-11-22 14:39

    Dan, from my experience (that includes implementation of SMIL2.1 language in JavaScript, where time management is in subject) I can assure you that you actually never need high precision of setTimeout or setInterval.

    What does however matter is the order in which setTimeout/setInterval gets executed when queued - and that always works perfectly.

提交回复
热议问题