Earlier quoted context omitted.
This is for site performance and not for general OS performance.
"Does your computer run out of battery 10x faster while on the site" should be a site performance issue if it's something in the sites js thats eating the battery.
Show HN: Speed up your site by running JavaScript when the browser is idle
41–50 of 95 posts
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#42Earlier quoted context omitted.
requestIdleCallback isn’t something that you need to protect yourself from. It just executes a function when there’s nothing else happening on your page essentially.
You mean my browser still doesn't use enough CPU? I don't want sites that aren't in focus to do anything.
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#43For some scripts "facade" solution might work even better than running them on idle. Consider a "chat plugin", that usually pops up each time you visit. If we'd replace chat script with simple dummy button, that loads actual script when user really needs to talk to website support - visitor wins as they are not bothered by popups and site loads faster.
Any ideas how to apply this idea for more 3rd party scripts, especially tracking ones?
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#44Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#45This looks well-designed and I'm sure somebody has a usecase for it, but I'm not sure I've ever had one
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#46Earlier quoted context omitted.
Do they? To do what when the computer is idle ? Those are interactive applications, there's not that much work for them to do when you're not interacting with them.
It's not about the computer being idle. It's about waiting for the main thread to be unblocked before doing stuff you would want to do anyway, but now you can schedule it for later to give priority to more urgent tasks. A very common optimization technique in all sorts of software and I don't see why it wouldn't be valid for a web application. Go read https://developer.mozilla.org/en-US/docs/Web/API/Background_... fo…
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#47As other comments have pointed out, this behavior is enabled by `requestIdleCallback`. MDN has a good example and looks like this is not supported by Safari - https://developer.mozilla.org/en-US/docs/Web/API/Background_...
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#48Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#49As other comments have pointed out, this behavior is enabled by `requestIdleCallback`. MDN has a good example and looks like this is not supported by Safari - https://developer.mozilla.org/en-US/docs/Web/API/Background_...
It's currently an experimental feature that can be enabled, so hopefully Apple will enable it by default in 2023.
Re: Show HN: Speed up your site by running JavaScript when the browser is idle
#50What's the use case? What is "your site" doing that it would need all this computing power?
The downside is it potentially introduces “jank”, where incremental changes render temporarily, and computation time is somewhat slower overall. In my experience/opinion, the tradeoff is worth it around 100-200ms depending on what’s being unblocked.