Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

javascript - What is minimum millisecond value of setTimeout?

I would like to put

var minValue = 0;
if ( typeof callback == 'function' ) {
    setTimeout( callback, minValue );
}

this code when I implement callback function with JavaScript.

But I've found that modern browsers and some old browsers

have different minimum timeout value.

I know that Zero cannot be minimum value.

What would be minimum value of setTimeout for

modern browsers and some old browsers for compatibility issues?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think that 10 will be the most reliable minimum in all browser, since I've seen a lot of codes using it.

However, 4ms is the minimum for HTML5

In fact, 4ms is specified by the HTML5 spec and is consistent across browsers released in 2010 and onward. Prior to (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2) , the minimum timeout value for nested timeouts was 10 ms.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...