News for hackers. Stuff that matters.
Re:Breaking up with JavaScript front ends by waboremo on Saturday December 10, 2022 @03:59PM (#33936738)
Tools like htmx aren't the reason the gmail tab uses a GB of memory. You'll find the majority of cases where pages are using way more resources than it should, are due to reasons forced on web developers, like a billion different trackers and several different ad networks, and workarounds to ad blocking to sell more subscriptions, etc.

This is what is so shocking to me when HN spends such an absurd amount of time rallying around this idea that frameworks are the reason sites are bad. Mind you, I do think a lot of them are misused, but 99.9999999% of poor websites aren't because of the framework chosen.

Re:Breaking up with JavaScript front ends by t8sr on Saturday December 10, 2022 @04:18PM (#33936893)
According to my browser, the default view in gmail needs 8.32 MiB of javascript spread over 90 files to render.

While IDLE, the gmail tab uses 10-30% of an M1 CPU core.

That stuff is not down to tracking - it's because the damn thing keeps messing with the DOM, because it has some insane structure where javascript controllers are attached as strings to DOM elements, because it uses about 100 divs to render every row in the list of messages, and because every message is nested literally 15-30 layers deep in a pointless tree of divs.

I am sorry, but web frontend is an insane dumpster fire.

Re:Breaking up with JavaScript front ends by wruza on Saturday December 10, 2022 @06:09PM (#33938050)
I haven’t tested the following claim and not at the computer atm (^U, see below), but divs must be cheap. They’re just structures which a rendering engine walks through and computes hierarchical offsets of via stylesheets.

I’m not arguing for using hundreds of divs, because that’s a sign of engineering insanity imo, but it’s not a performance issue. You can create a static page with thousands of them and (likely) see that it still doesn’t use 250Mb+ neither idles at 30% cpu core.

Added:

damn thing keeps messing with the DOM … web frontend is an insane dumpster fire.

Totally agree with these parts.

—————

… I just tested 50 div-rows with 200 spans containing numbers from 1 to 199. Total 10k elements, text doesn’t fit on the screen. Bootstrap css+js is imported via CDN.

Mithril.js implementation uses 50Mb of RAM consistently.

A static page with the exact same content uses 71-96Mb depending on the run.

Both use 5-14% cpu when I shake my mouse and 0% when I don’t.

Refresh is significantly faster with Mithril, idk why, probably because static html parser is slow. (Opera, Windows 10, no extensions).

With a single span per row instead of 200 both take 23Mb.

Removing bootstrap from the head inconsistently frees 0-2Mb for both.

Re:Breaking up with JavaScript front ends by minusf on Saturday December 10, 2022 @07:36PM (#33938652)
maybe they are cheap, maybe not. but lighthouse prints a warning for "excessive number of dom elements" already at 1500...
Re:Breaking up with JavaScript front ends by smoldesu on Saturday December 10, 2022 @05:06PM (#33937391)
What browser are you using? Having Gmail open doesn't even use half of a percent of a single core on my machine (Linux, x86, Chromium).
Re:Breaking up with JavaScript front ends by t8sr on Sunday December 11, 2022 @01:42AM (#33940739)
Chrome on an M1 Pro Mac. This is the number that Chrome’s task manager shows me.

I do have a lot of emails, but I think it should only have to worry about 100 of them at a time, so I don’t know why it’s different for me and you. It is possible that my account still receives beta features, because I used to work there, but I remember it being like this for multiple years, since the new gmail came out.

Re:Breaking up with JavaScript front ends by smoldesu on Sunday December 11, 2022 @10:54AM (#33944217)
Are you using Chrome through Rosetta? I'm still unable to replicate this on either my desktop or laptop, both of them just idle when I open Gmail and neither will push past 5% usage while I'm opening emails. Your metrics seem a bit odd here.
Re:Breaking up with JavaScript front ends by vbezhenar on Sunday December 11, 2022 @12:59AM (#33940518)
Same for macOS, Chrome. CPU sometimes jumps to 3%, but that's about it (and I guess that's because it uses slow core).

I have very clean mailbox, though.

Re:Breaking up with JavaScript front ends by Throwaway23459 on Saturday December 10, 2022 @10:50PM (#33939873)
Well google use all of their own internal 'frameworks', so you can't really use their web applications to judge the rest of the web.
Re:Breaking up with JavaScript front ends by t8sr on Sunday December 11, 2022 @01:44AM (#33940749)
This used to be true but isn’t anymore. For a while they pushed Angular, nowadays I think a lot of teams are using react. GWT is long deprecated and gone.
Re:Breaking up with JavaScript front ends by mattlondon on Sunday December 11, 2022 @07:23AM (#33942569)
I think citation needed on that one.

From what I understand (no special insider information) React is essentially non-existent inside of Google, and NPM is not even available to engineers (be default)

Re:Breaking up with JavaScript front ends by t8sr on Sunday December 11, 2022 @05:51PM (#33948471)
I am not sure how much I can say, because I used to work there. But I think it's OK to say many Google engineers don't particularly like Angular.
Re:Breaking up with JavaScript front ends by panopticon on Sunday December 11, 2022 @06:25PM (#33948774)
It depends what org you're in. Cloud seems to use a lot of Angular, but the rest of the company is coalescing around an in-house framework called Wiz (you can poke around the open sourced jsaction library to get an idea of the design philosophy).
Re:Breaking up with JavaScript front ends by kaba0 on Sunday December 11, 2022 @05:21AM (#33941940)
To be fair, gmail was quite great at the time of GWT. Not sure how much use their Clojure “platform” still get, but I think it was very ahead in terms of maintainability of large js code bases (or even ahead as we have it now)
Re:Breaking up with JavaScript front ends by DHPersonal on Sunday December 11, 2022 @12:14AM (#33940337)
I keep saying the same thing at work on the NextJS / MaterialUI project I’m working on and I largely get blank stares in response.
Re:Breaking up with JavaScript front ends by smaudet on Saturday December 10, 2022 @04:21PM (#33936928)
If you can limit yourself to exactly one, maybe two external deps, which are really just to make your dev life eaiser, you may have something of a point.

You have to remember that a large chunk of "web apps" means "electron apps" which are absolute bloated pieces of junk next to their desktop cousins.

You also have to remember a 'framework' typically doesn't stand in isolation - tens, hundreds, thousands of dependencies typically lurk.

We all agree tracking junk makes it even worse, but the whole thing is already overcomplicated before you get to that point.

Re:Breaking up with JavaScript front ends by ryanbrunner on Saturday December 10, 2022 @05:17PM (#33937501)
> You also have to remember a 'framework' typically doesn't stand in isolation - tens, hundreds, thousands of dependencies typically lurk.

While this is true, at least by having a large number of people commit to the same set of dependencies, you stand a higher chance of complications between those dependencies being ironed out, either directly by the framework maintainers or by the user base of the framework.