I’ve prepared npm package with the BrowserPriorityTimers
class. It gives you ability to use timers that will not be throttled by the browser. This maybe useful at times when you want to keep your timers execute without interruption even when the tab is inactive. You can install it with the npm i browser-priority-timers
command.
if (!timers.workerAvailable()) {
console.warn("Priority timers are not available for this browser");
} else {
console.info("Priority timers are available");
timers.setTimeout(() => {
console.log("setTimeout on worker.");
}, 1000);
}
Code language: JavaScript (javascript)
Whenever you need a timer with a priority use the one provided by the BrowserPriorityTimers
class. I hope you enjoy it.