Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make JavaScript run at normal speed in Chrome even when tab is not active?

I've noticed a problem with my webapp - when Chrome active tab isn't set to my app, Chrome stops running my JS code until I open tab again.

I guess it does to save CPU cycles. Else if you've 20 tabs open and each has code running, it will get slow quickly.

This is all good, but my app requires that it keeps running in the background. It updates graphs in real time and analyses data every few seconds.

If I move to another tab, graph updating and analysis stops (or becomes very slow - 1 second is now like 20 seconds). Then when I focus on tab again it resumes updating at normal speed but the graphs and data analysis gets weird because of this weird time dilution.

like image 779
bodacydo Avatar asked Sep 04 '15 05:09

bodacydo


1 Answers

Playing a faint sound seems to unlock full javascript performance in the background, yet, using websockets does not

Here's a more lengthy answer I've written: https://stackoverflow.com/a/51191818/914546

like image 92
Kaan Soral Avatar answered Oct 13 '22 03:10

Kaan Soral