Hacker News new | ask | show | jobs
by rochoa 4884 days ago
The timeLeft -= 1000 approach is not the best one because setTimeout doesn't guarantee when the next tick is gonna happen.

Just open the JS console and type:

  for (var i = 0; i < 1e7; i++) {}
You will block the JS execution and your next tick will happen when the loop finishes. Using new Date().getTime() should do the job.

Edited for formatting.

2 comments

Scrolling in iOS also stops setTimeout being called.
I fixed that, thanks :)