3

Chapter 6 "Responsive Interfaces" of "High Performance JavaScript" book by Nicholas C. Zakas says the following thing about Timer Precision:

Timer resolution on Windows systems is 15 milliseconds, meaning that it will interpret a timer delay of 15 as either 0 or 15, depending on when the system time was last updated. Setting timer delays of less than 15 can cause browser locking in Internet Explorer, so the smallest recommended delay is 25 milliseconds (which will end up as either 15 or 30) to ensure a delay of at least 15 milliseconds.

What is the meaning of "browser locking" here? Does that mean that widely used approach setTimeout(task, 0) to move a task to the end of UI thread queue can make IE hang?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Andrey
  • 6,526
  • 3
  • 39
  • 58
  • 4
    never had problems with setTimeout(t, 0), using it since ie6. duplicated question [see here](http://stackoverflow.com/questions/779379/why-is-settimeoutfn-0-sometimes-useful) –  Oct 11 '12 at 16:14
  • 25 ms? That's not even 40 FPS in an animation! ^^ – Bergi Oct 11 '12 at 16:19

2 Answers2

3

setTimeout runs your task once, I don't think this will cause a lockup.

My interpretation of your book snippet is that he is referring to repeated executions, such as with setInterval. If you set code to execute every 0 milliseconds, then yeah, I could see IE having a problem with that.

uberdanzik
  • 549
  • 1
  • 7
  • 18
0

I have been using it and no I have not experienced any issues with it. It allows the browser to use time slots for its rendering thread which actually is very useful in some cases.

Konstantin Dinev
  • 34,219
  • 14
  • 75
  • 100