1

I am analyzing performance of existing UI application using Chrome developer tool and have noticed a really strange behavior - from time to time (about 5-10%) browser just idles before executing the script from setTimeout(). I've googled a lot, and I've found a lot of answers that browser puts the script into the end of queue, so it waits until all other tasks are finished.

Yes, but it waits a lot more! From 10ms to 800ms more!

Chrome performance tool

Image

The code which sets this timeout looks pretty much like: y.setTimeout(a, 0)

  • Is it a Chrome 65 issue?

  • Is it real or can be seen only in developer tool?

  • Is there a way to eliminate this and force script to execute ASAP after the time has come (in this case - immediately after other tasks have been finished)?

halfer
  • 19,824
  • 17
  • 99
  • 186
Yegor
  • 21
  • 3
  • Have a look at [this](https://stackoverflow.com/a/10740558/1048572) – Bergi Apr 12 '18 at 12:49
  • "*Is there a way to force script to execute ASAP after the time has come (in this case - immediately after other tasks have been finished)?*" - What is the [actual problem](https://meta.stackexchange.com/q/66377) that you need this for? – Bergi Apr 12 '18 at 12:51
  • @Bergi The actual problem is overall performance of the page. It often fails to finish everything in 2 seconds. – Yegor Apr 13 '18 at 10:30

1 Answers1

1

Found an answer in related question: this happens when tab is inactive, because timers in inactive tabs fire once a second, so waiting "overhead" is floating from 0 to 1 second. Feels like not a real performance problem for users, but a real problem for our performance measurements...

Yegor
  • 21
  • 3