jeudi 31 décembre 2020

How to disable browser CPU throttling on SetTimeout?

When the browser is minimized or the tab is on the background they set setTimeout to a minimum of 1 second example code:

const wait = ms => new Promise(r => setTimeout(r, ms))

async function doStuff() {
    let p0 = performance.now();
    await wait(100);
    let p1 = performance.now();
    console.log('time',(p1-p0));
    await doStuff();
}

When the tab or the browser is on focus the console.log prints 100, when it's minimized 1000 how I can disable/bypass it?




Aucun commentaire:

Enregistrer un commentaire