For example, this very popular thread: https://news.ycombinator.com/item?id=43561253&utm_term=comment
If you collapse the top comment, I see a huge spike in CPU and my system freezes temporarily.
Is it just me?
For example, this very popular thread: https://news.ycombinator.com/item?id=43561253&utm_term=comment
If you collapse the top comment, I see a huge spike in CPU and my system freezes temporarily.
Is it just me?
16 comments
The Javascript is surprisingly readable (not minimized, not using any framework). It looks like all the comments are peers according to the DOM structure. When it collapses a comment, it loops through all the following DOM siblings until returning to the same indent level (so all the semantic descendants) and hides them one-by-one. I could see why this could be a bit slow even though it isn't for me. I'm not really a frontend person so I don't know why they might have chosen this structure. One could imagine if the DOM structure were set up such that the comment's descendants were DOM descendants, it wouldn't have to do this at all. It could just use a CSS selector that would hide elements (and thus their descendants also) if their direct parent were collapsed.
I know, for instance, that Dark Reader seems to affect my CPU usage when mass updating DOM elements like that.
And I suppose it depends on your CPU, if you're running modern browsers on a fifteen year old laptop you're going to see CPU spikes all over the place.
I just timed it real quick in Edge 134.0.3124.93 and collapsing svara's top level thread hangs the browser and lags my system for 1 minute 36 seconds.
Judging from the other commeters who didn't noticed spikes, I think there might be something related to your hardware and software combo that is causing it.