1

How do I get a script to run in my browser with a timer of at least 15 minutes? Right now I'm running into an issue where standard browsers throttle time once a page becomes inactive, which is throwing out my timer. I can't figure out how to integrate a webworker although this seems like it could be a solution.

const timer = 1000 * 60 * 15

setTimeout(test, timer)

function test() {
    console.log("worked");
}

Is there another, simpler way to run the test function after 15 minutes other than a webworker? Or is there a video/tutorial that might help me figure out webworkers?

econobro
  • 315
  • 3
  • 17
  • Maybe Using Nodejs. – Leyiang Jan 20 '22 at 04:03
  • It's throttled, but not stopped completely IIRC - are you doing anything CPU intensive? If so, don't, and see if it makes a difference. Heavy work in inactive tabs isn't allowed, but very light work might be OK - though the timeout time might not be precise – CertainPerformance Jan 20 '22 at 04:14
  • Whatever you intend to do after 15 minutes can wait until the page moves to the foreground, right? – Ouroborus Jan 20 '22 at 04:16

0 Answers0