2

Last year, Chrome shipped a feature to increase battery life by limiting JavaScript timer wake ups in background webpages.

setTimeout(()=>{
  console.log('done')
}, 1000)

The code above will print logs after 1 second.But when the webpage is in background, it will print after about 10 seconds. It causes a lot of problems.

So, are there any solutions can prevent Chrome from throttling my timers?

WhiteYin
  • 25
  • 4

2 Answers2

2

You could try loading the script when the window is active, but if it can't be helped, HackTimer.js is a good workaround using Web Workers.

GockOckLock
  • 138
  • 1
  • 10
1

There are possible solutions provided in following threads:

  1. Chrome: timeouts/interval suspended in background tabs?
  2. How can I make setInterval also work when a tab is inactive in Chrome?

Hope you've checked this.