Live data from Hacker News

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

npmjs.com

31–40 of 95 posts

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

#31
post #6

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

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.

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

#35
post #24

Earlier quoted context omitted.

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.

Actually I wasn't thinking of bitcoin, but for example of needless auto refreshes and animations. Seriously, web devs need to learn to respect my battery and electricity bill more.

This does not do what you think it does. You're tilting at windmills.

It's not about doing stuff in a tab that isn't in focus. "Idle" refers to the main thread idling in the page you're currently using, so it's about controlling the execution order and priority of JS tasks. E.g. on Google Maps you give priority to rendering the visible map tiles while deferring preloading the surrounding non-visible tiles until the main thread is unblocked (and thus idling).

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

#36
post #34

What's the use case? What is "your site" doing that it would need all this computing power?

What kind of question is that? Games or applications like Figma obviously require more computing power than a static homepage.

Figma isn't my site.

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

#37
post #6

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

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

Is... is it bad that I think that might not actually be so bad? I never had an issue with full page reloads of a damn blog, but somehow it's all SPA garbage these days and all the sites have errors in one or more browsers but miraculously keep chugging along (except when they don't and there's a blank page).

At least in the old days if CSS or JS didn't load, you still got a semi-usable page.

Turning HTML+CSS+JS into an application platform has been one of the most fundamentally stupid things we've done as a field and we'll keep paying for it for years on end, second only to not adding slices to C.

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

#38
This comment thread is a serious mess with all sorts of bad faith takes that have nothing to do with the library. Go read https://developer.mozilla.org/en-US/docs/Web/API/Window/requ... and https://developer.mozilla.org/en-US/docs/Web/API/Background_...

This is not used for malicious CPU hijacking or whatever. It's a way to schedule low-priority JS tasks for later when the main thread is unblocked and give priority to more important things. It's a very useful API for when optimizing games or complex web applications.

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

#39
post #34

What's the use case? What is "your site" doing that it would need all this computing power?

What kind of question is that? Games or applications like Figma obviously require more computing power than a static homepage.

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.

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

#40
post #39
post #34

Earlier quoted context omitted.

What kind of question is that? Games or applications like Figma obviously require more computing power than a static homepage.

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_... for a better explanation.
Post reply on HN