Live data from Hacker News

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

npmjs.com

81–90 of 95 posts

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

#81
post #31

Earlier quoted context omitted.

you are absolutely right. we should completely throw away the development of browser APIs over the years and develop sites with html 4.0

The web was a much better place 10 years ago.

a sweet spot?

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

#82
post #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.

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

That's right. I changed README to everyone to understand it.

https://github.com/hiroki0525/idle-task#features

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

#83

As 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_...

`idle-task` has shim as below .

https://github.com/hiroki0525/idle-task/blob/main/src/index....

References - https://developer.chrome.com/blog/using-requestidlecallback/...

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

#84
post #69

Earlier quoted context omitted.

It's always Safari. I never figured out why.

The 3 biggest browser engines are Gecko, Webkit, and Blink. Gecko is the engine behind Firefox and is maintained by Mozilla, so it has a good number of open source contributors that help fix issues when they are found. It also has some issues occasionally but since it has only a ~3% usage these days you don't get as many complaints. Blink is used by Chromium (which includes Edge, Chrome, Opera, Brave, and Samsung bro…

Google could let Chrome rot: Microsoft let Internet Explorer rot back in the days before Edge (primarily because Microsoft recognised that browsers would compete with their Windows monopoly: which is exactly what happened).

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

#85
post #21
post #6

I have an idea: why not speed up your site by NOT running js at all?

That's a fine personal choice but don't snarkpoop on other people's Show HN's. https://news.ycombinator.com/showhn.html

If other people's choice had no influence on me, I would totally agree with you.

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

#86
post #68
post #60

There's lots of confusion what this is. Basically browser runs a giant eventloop. Whenever you call async function in javascript, it gets put into a queue, and called by the event loop (usually the next execution). This basically makes it so that the async call gets tagged with metadata that tells the event queue "Don't call me unless you have nothing else to call". So basically it keeps the async call at the end of…

Lol, thanks. This comment was better than the docs, as usual.

Sorry for the confusion.

>this is a convenience wrapper around “requestIdleCallback” That's right. I changed README.

https://github.com/hiroki0525/idle-task#features

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

#87
post #85
post #21

Earlier quoted context omitted.

That's a fine personal choice but don't snarkpoop on other people's Show HN's. https://news.ycombinator.com/showhn.html

If other people's choice had no influence on me, I would totally agree with you.

It's not a matter of agreement, it's just that this sort of comment is offtopic in Show HN's.

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

#88

The code: https://github.com/hiroki0525/idle-task/blob/main/src/index.... Some initial impressions (based on https://github.com/hiroki0525/idle-task/blob/7e88c8b97c926cf... ): • The cancelIdleCallback fallback implementation will never be defined, so cancelAllIdleTasks will unexpectedly throw an exception in environments like Safari that depend on the polyfill. (Solution: delete lines 14–15.) • That the simple fallba…

Thank you for your good code review! In most cases, I agree with you. I will improve the code as you said gradually.

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

#90
post #87
post #85

Earlier quoted context omitted.

If other people's choice had no influence on me, I would totally agree with you.

It's not a matter of agreement, it's just that this sort of comment is offtopic in Show HN's.

> When something isn't good, you needn't pretend that it is,

from the link you provided…

Post reply on HN