Live data from Hacker News

Show HN: Speed up your site by running JavaScript when the browser is idle

npmjs.com

11–20 of 95 posts

Re: Show HN: Speed up your site by running JavaScript when the browser is idle

#13
post #2

What I’d really like to see on this page is more descriptive text. Mainly a description of what’s actually being done by the library. But also a section on when I should use idle-task over Partytown - https://partytown.builder.io/

I agree. The README file presents it like an alternative to `requestIdleCallback`, while, in fact, it is a convenience wrapper around `requestIdleCallback`. It is a nice idea, but the description makes it confusing.

Re: Show HN: Speed up your site by running JavaScript when the browser is idle

#14

Couldn’t this have negative impact on user battery life depending on the weight of the JS or number of open tabs with sites using it? Seems like it might be antagonistic to host OS efforts to to coalesce work and perform it while the CPU is already awake to reduce the number of wakeups and save power, since it specifically waits for browser idle.

This is for site performance and not for general OS performance.

Re: Show HN: Speed up your site by running JavaScript when the browser is idle

#16
post #4
post #3

One of the extensions that suspends idle tabs can protect me from this?

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.

A bit of remote browser crypto mining?

Re: Show HN: Speed up your site by running JavaScript when the browser is idle

#17
post #7

I actually like having software and hardware that can be idle. I find it quite peculiar that some app/window/page I'm explicitly not interacting with should be doing work because I'm not interacting with it.

The idea is that you schedule low priority work to happen with requestIdleCallback (which this is just a wrapper around), so it doesn't impact as much higher-priority tasks like responding to input or animations.

For example, you may schedule periodic API polling (and JSON response parsing) using this API to prioritise user input handling.

I would guess (but not know!) that the browser could de-prioritise these tasks even further when the browser decides to (such as when in the background).

Re: Show HN: Speed up your site by running JavaScript when the browser is idle

#20
post #9
post #4

Earlier 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.

The point is to play nice. "I have this task the page needs to do, but I can wait a bit until more convenient". Not "browser is idle, let's mine some bitcoin" as you suggest.
Post reply on HN