Hacker News new | ask | show | jobs
by nanidin 4898 days ago
In theory yes. But... most browsers throttle javascript timers of tabs that are not in the foreground. For example, here's a commit for Chromium that limits the firing of timers for background tabs: https://codereview.chromium.org/6577021.

I can't find the particular commit/issue for Webkit, but the authors expressed that they were using the timer limitation to prevent non-foreground tabs from sucking up CPU time. Others came along with workarounds (scheduling 1000 timers at 1ms intervals that will each fire once per second) and the authors said if they saw something like that being put to practice, they'd have to re-evaluate their method for limiting javascript usage by background threads.

1 comments

This issue is actually very visible in the example I have on the quuen home page. If you don't have the tab in the foreground, the script will execute more slowly than if its in the foreground. This isn't an issue if you're spawning browsers with the purpose of using them as computation nodes (so their tabs are in the foreground), or for applications that aren't very chatty with the back end.