> Avoid an excessive DOM size
No
Zach Leatherman 5050 replies 5757 likes33 reposts Original on MastodonOriginal on BlueskyAlso posted to Mastodon.
50 replies
@zachleat Browsers should do better than size-shaming
@alesroubicek especially not at 800 nodes, c’mon
@zachleat @alesroubicek Agree that 800 is an excessive threshold size, but I like the trigger to question whether there might be a way to make the DOM leaner.
We saw nice benefits for mobile users when we switched to incremental loading of upcoming events (chunks of 7 days) for a state opera website. Now initial load contains ~900-1000 DOM nodes instead of ~16.000.
`content-visibility` will for sure be a player here, but we had too many accessibility concerns when we investigated it last year.
@polarbirke @zachleat When you do incremental loading, you still end up with ~16.000 nodes in the end. :) We need a native virtual scroller for this.
@alesroubicek @zachleat You're right!
But… it depends on the scenario.
Sure, if you scroll down into the future until you load events for Christmas, you'll get to 16k.
There's filter by month feature though and the server returns a new page with (again) only events for the first 7 days of that month.
Also, most visitors either look for events that happen soon (like, within a fortnight, because they're local) or far away (like, in a few months because they're tourists arriving on vacation).
@alesroubicek @zachleat Not sure if a native virtual scroller would be needed or if content-visibility is going to be the catch-all already, but obviously we and the state opera are nowhere near the end of the journey.
I just wanted to make a (small) case that the DOM node threshold can lead to something good. 😁
In this economy?!
@webbureaucrat @alesroubicek *exactly*
@zachleat but doesn’t jQuery work better that way?
@mikehoss it used to matter a lot before querySelector! But erroring at 1400 nodes — I’m trying to feed my family here
I replaced SVGs with PNGs in some software that ran on very old hardware and the results were incredible. I now take that suggestion a little more seriously (though maybe an edge case).
<img src="/bluesky/zachleat.com/3llbwstjev22z/svg"> would work too!
That was a while ago... I hope I tried that. Honestly don't remember, though.
@zachleat I'm being told that too by Lighthouse but my DOM has 49,000 nodes, so I have to hold my hands up.
In reality, with content-visibility: auto on my repeated nodes, it still performs quite well, but I'll give it a trim.
@chris22smith ok wait 49K is wild
@zachleat It's one of those badly designed all data ever scenarios. It'll just keep going till it snaps.
@zachleat Dude all you have to do it put you entire JS bundle/workflow behind a `setTimeout(work, 3000)` and you will ace that test EVERY TIME!!
@westbrook client rendering is always faster weeeee
@zachleat *looks at https://www.w3.org/WAI/WCAG22/quickref/*
@yatil see, they get it. 9616 nodes is barely a scratch!
@zachleat Hehe :-) For the amount of content that is in there, it really is not that much. It has an HTML file size that is smaller than most of the JS frameworks these days, and yet I had a lot of doubts putting a file that size.
(Tho that was with Flash and Silverlight techniques which balooned to over 1MB, if I recall correctly.)
@yatil clearly a 🏆.
https://www.11ty.dev/speedlify/ is 8104! we’re all in this one together
Isn't this the opposite of what Shadow DOM encourages?
especially on a hot and sunny day
depends if it’s closed or open, I think?
Rude.
Cannonball run!!
Every problem can be solved with a finite number of divs
640K should be enough for anybody — wait
I heard divs are turning complete
@zachleat 🎶 I like big DOMs and I cannot lie 🎶
@zachleat If it can’t fit in a `<div id="app"></div>`, I don’t want it.
@jgarber 100K nodes or bust
Lighthouse just wants you to have <body> be the lowest nested element on the entire page.
Apparently, all hell's going to break loose if you embed SVG code in your markup. 😂
we need an SVG minifier that converts a complex SVG into a single path 😅
or some kind of linear-gradient magic to apply to a single div. No nesting AT ALL!! 😂
everything must be a.singlediv.com sorry @lynnandtonic.com you’re in charge of everything now
I accept
I know a guy called Dominic who is 6ft 11.
ludicrous
this is how the fast and furious franchise started
I will watch one or all of these films tonight so I can understand this better
Fast & furious through Hull
Fast & furious through Hull 2: With your eyes closed
Ludicrous
I only ask that you watch the one where they drive their car to space
hide complexity in iframes, and hope Lighthouse does not notice :)
delete ads, hope client doesn’t notice 😅