I would use the <details> tag to solve this problem. Most people don't know this exists and I have no idea why. You would probably have to rewrite the html so it no longer uses tables but I don't really consider that to be a negative.<p>I would also question why we are saving collapsed comments. I feel like this is something that doesn't need to be persisted forever. If you want this behavior why not use local storage instead?
Fun fact<p>In a previous company we were building a session replay tool, and as you may know it is pretty complex to evaluate the impact of the single script on a page.<p>The only way we found to test the impact of the script was to execute it on a page with the most mutations on an event, and try to see how much the event was impacted.<p>The only place where we found a heavy use of mutations was the hackernews page that had more than 100 comments in a thread. And the first time we tested, we tripled the time to collapse the thread
> There is also a GET request to <a href="https://news.ycombinator.com/collapse?id=1234567" rel="nofollow">https://news.ycombinator.com/collapse?id=1234567</a> to save the state of the collapsed/expanded comment if the user is logged in, but it's an async request so it doesn't have an impact.<p>Is this a correct place to use 'GET'?
I have a budget moto and HN comments section is completely unusable on Chrome but perfectly smooth on Firefox. Haven't explored why.<p>On Chrome any comment section with more than about 100 comments grinds to a halt. If I try to type in a comment there's a three second delay waiting for every letter to appear.
Or just use my Greasemonkey/Tampermonkey plugin which disables the Hackernews collapsible comments and introduces its own collapsible comments logic, which is much faster and has a variety of convenience features:<p><a href="http://mental-reverb.com/creations.php" rel="nofollow">http://mental-reverb.com/creations.php</a>
I suspect the pg answer to this question is "there's too much noise on some posts, and deterring interaction with posts of 300+ comments is a feature, not a bug.
I am just now realizing that HN comments are collapsible...I wonder if anyone has ever looked at upvote/scroll behavior when the collapse button is used vs not? There are a ton of threads where the top comment is also a non-sequitur, but I know when that happens I frequently don't scroll past the hundreds of replies to see what the other first level comments are.
I wrote a browser extension to collapse HN comments past the first depth and ended up just attaching their css classes and setting the sub-comment count myself. It was the fastest behavior I could find at the time for reasons I've since forgotten. I did try to use their existing js but it took forever to collapse the page.<p>Here's my collapse code if interested<p><a href="https://github.com/a13o/disengaged/blob/master/src/hacker-news/collapse-deep-comments.js" rel="nofollow">https://github.com/a13o/disengaged/blob/master/src/hacker-ne...</a>
A lot could be gained by simply storing the jQuery objects instead of doing the lookups multiple times per method. That’s a lot of unnecessary dom traversal.
I dug into the collapsing code recently because I wanted to make a script that collapses HN threads by default. In other words, only the top-level comments would be shown at first. To me this makes more sense. If I am interested in continuing a thread, I can expand it. If I am not interested in continuing, I don't want to have to scroll past its children.<p>According to the comments here, maybe I would be better off implementing my own collapsing scheme.
If you don't mind me being negative here for a moment:<p>1. It's not your website, why spend so much time and effort on dissecting the issue? If one did this for every webpage they visited it'd be a more than a full time job.<p>2. Does it really look like Hacker News has had any serious development effort poured into it anytime recently? What incentive does YC have to put time and money into a forum that generates zero revenue?<p>3. Do we really expect web browsing to be pleasant on a 3 year old budget smartphone with a Qualcomm 617?<p>The Moto G4 Plus is solidly in the bottom 25% of phones listed here:<p><a href="https://www.androidbenchmark.net/cpumark_chart.html" rel="nofollow">https://www.androidbenchmark.net/cpumark_chart.html</a>