Live data from Hacker News

The browser's main thread is expensive

kciter.so

151–158 of 158 posts

Re: The browser's main thread is expensive

#151

Earlier quoted context omitted.

I challenge you to browse the web one week on this laptop part of the current top 10 Amazon best sellers on a gigabit fiber connection and tell me if you still think that this is the problem: https://www.amazon.com/HP-Everyday-Processor-Microsoft-Porta...

> 【Processor】AMD Processor > 【Graphics】 Intel Graphics And this is why you don't buy laptops from Amazon. At best, the seller has no idea what they're doing, at worst, this is fraud.

my point is that as programmers we have to take into account that the average human today has a computer that likely struggles to open Win11 notepad. I don't buy random laptops from amazon, but an astonishingly high amount of people do and we have to work with that

Re: The browser's main thread is expensive

#152

Earlier quoted context omitted.

I'm not sure the author realises _what_ a massive impact bundle size has on the main thread though, especially hydration. The majority of apps I've optimised over the years have the (often vast) majority of main thread time spent on the bundle parse/hydration (plus obviously network). Also, removing dependencies is not easy. I've seen many corporate that have a huge UI lib for example that everyone should use for bra…

All good points. Perhaps rather than saying the fixes are straightforward, I should have said it's a straightforward concept to understand. If your app takes forever to load because of a huge bundle, you need to figure out how to make the bundle smaller, somehow. (How exactly to do that is where it gets complicated, like you say.)

Tbh its not just that, you can have small bundles which hydrate extremely poorly.

But yes, I think we are in agreement :).

Can you tell I have mental scars from nextjs bundle optimisation?

Re: The browser's main thread is expensive

#153
post #128

Earlier quoted context omitted.

Okay so that's no excuse for whoever is providing your internet, coax can deliver 800+ Mbps no problem. And if you are actually saying you only get DSL through a phone line in London then holy shit I would be busting down the door of my landlord. They never in the last half a century got wired for cable?!

A phone line from before WWII works fine to make a call but absolutely sucks for DSL. And in London many buildings are declared as historic making it hard to get a permit for any work. The best chance is to wait until old pipes bursts and digging has to be done in any case to put fiber along the pipes.

It's not that, it's the building owners (freeholders) refusing permission, or not replying. It's a massive issue.

You'll notice buildings in central London that are listed _but_ have housing association ownership nearly all have fibre to each apartment, as they did portfolio wide deals with hyperoptic etc.

And pipes don't help. Openreach (who owns the copper network) are not allowed in 99% of cases to "fix" copper with fibre under the agreements they have with building owners, they can only make like for like repairs.

The worst affected apartment buildings are 90s and pre 2015ish. Everything after that got fibre installed at build time.

Btw it is worth checking if you have an altnet like hyperoptic, community fibre or g network available. The majority do and if you are just checking for openreach or VM broadband it won't show up.

Re: The browser's main thread is expensive

#154
post #66

Good article and I wish this was much better known. The issue is though that it's too focused on interactivity. In reality, 90%++ of slow sites are not slow because of interactivity really, they are slow because they ship enormous react/nextjs bundles and have extremely heavy hydration work to do. _so many_ sites have bundles >10MB that need to be downloaded, parsed and hydrated. I've even seen (many) sites which hav…

99% of the time those sites could be plain HTML and CSS, but apparently new generations don't even know how to do that, out of programming bootcamps.

I expect soon each website will have its own browser, compiled as WASM which will be launched in order to render the JavaScript and HTML on the website.

Re: The browser's main thread is expensive

#155
post #66

Earlier quoted context omitted.

99% of the time those sites could be plain HTML and CSS, but apparently new generations don't even know how to do that, out of programming bootcamps.

I expect soon each website will have its own browser, compiled as WASM which will be launched in order to render the JavaScript and HTML on the website.

This is actually plausible as a way to prevent adblock.

Re: The browser's main thread is expensive

#156
post #137

Earlier quoted context omitted.

Cooperative multitasking isn’t universally a bad idea (in fact, Rust supports it)

I can't think of a better way to make simple things billions of times slower than they should be.

> I can't think of a better way to make simple things billions of times slower than they should be.

How's it going to do that? What's so bad about it? Especially in the multi-core era which lets multiple programs run at the same time the way that multiple pages can run javascript at the same time. The lack of preemption is only within a single page/program.

During periods of time where no single chunk of code runs for more than a millisecond, cooperative multitasking should have the exact same performance as preemptive multitasking. And even when single chunks of code do run for that long, if that code wasn't properly isolated then preemption doesn't save you from lag.

So the difference only shows up when you have chunks of code that keep running way too long, that are also inside of properly isolated threads/callbacks, and on web those threads/callbacks are not inside web workers. Is that a common situation?

Re: The browser's main thread is expensive

#157
post #66

Earlier quoted context omitted.

99% of the time those sites could be plain HTML and CSS, but apparently new generations don't even know how to do that, out of programming bootcamps.

I expect soon each website will have its own browser, compiled as WASM which will be launched in order to render the JavaScript and HTML on the website.

Basically Flash 2.0.

Re: The browser's main thread is expensive

#158

Earlier quoted context omitted.

>99% of the time those sites could be plain HTML and CSS, but apparently new generations don't even know how to do that, out of programming bootcamps. That is because the latest framework always fixes everything that wasn't broken before.

There is no good technical solution for rendering on the server and upgrading to an interactive experience on the client.

If you can tolerate the (fairly minor) SEO consequences, just render on the client exclusively and fetch data via http calls. I've made small but quite interactive websites with entirely static Svelte + some router (routify/sveltekit/etc.) SPA that just uses http calls for whatever the server needs to be involved in. It's not the right choice for everything, but for some things it works excellently. With a relatively lightweight frontend like Svelte, as well as splitting the SPA into multiple bundles (so it's in some ways not an SPA anymore) makes it perfectly usably snappy even over 200+ms latency, and very fast over a normal connection.
Post reply on HN