How can I make setInterval also work when a tab is inactive in Chrome?

后端 未结 13 1986
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 09:59

I have a setInterval running a piece of code 30 times a second. This works great, however when I select another tab (so that the tab with my code becomes inacti

13条回答
  •  梦谈多话
    2020-11-21 10:33

    Playing an audio file ensures full background Javascript performance for the time being

    For me, it was the simplest and least intrusive solution - apart from playing a faint / almost-empty sound, there are no other potential side effects

    You can find the details here: https://stackoverflow.com/a/51191818/914546

    (From other answers, I see that some people use different properties of the Audio tag, I do wonder whether it's possible to use the Audio tag for full performance, without actually playing something)

提交回复
热议问题