Live data from Hacker News

Why is collapsing a Hacker News comment so slow?

github.com

21–30 of 123 posts

Re: Why is collapsing a Hacker News comment so slow?

#22
I have a budget moto and HN comments section is completely unusable on Chrome but perfectly smooth on Firefox. Haven't explored why.

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.

Re: Why is collapsing a Hacker News comment so slow?

#23
post #5

> There is also a GET request to https://news.ycombinator.com/collapse?id=1234567 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. Is this a correct place to use 'GET'?

>Is this a correct place to use 'GET'? Not at all; GET requests are specified [0] to not cause any modifications to the resources (aside of meta-data like logging etc.). It should also be 100% safe for web spiders to issue any GET at any time [1], server overload aside. I presume it's an artifact of earlier implementation -or just an idea- to have the collapse work without JavaScript. It would be doable with a normal…

The 'logout' button is also a GET request.

Re: Why is collapsing a Hacker News comment so slow?

#25
post #19
post #12

Earlier quoted context omitted.

I might visit Hackernews using multiple user-agents.

is cross-session comment folding really that important/neat?

I would say it's more important than caring if something is a GET or POST on the backend.

Re: Why is collapsing a Hacker News comment so slow?

#26

> There is also a GET request to https://news.ycombinator.com/collapse?id=1234567 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. Is this a correct place to use 'GET'?

Isn't that vulnerable to CSRF? What if a page linked on the front of HN makes a request collapsing every single comment?

Re: Why is collapsing a Hacker News comment so slow?

#28
post #16

I would use the 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. 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?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/de...

This is awesome! I had no idea! You're right, I don't think most people even realize. There's often times I get upset when using Bootstrap or just doing CSS and look up ways to do specific things and don't find out of the box solutions, this is one time I'm glad I found a decent alternative. One case that comes to mind is collapsible trees and dropdown boxes where you can type / search on them, and anything with dropdown boxes like checkmarks gets a wee bit hacky.

Re: Why is collapsing a Hacker News comment so slow?

#29
post #16

I would use the 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. 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?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/de... This is awesome! I had no idea! You're right, I don't think most people even realize. There's often times I get upset when using Bootstrap or just doing CSS and look up ways to do specific things and don't find out of the box solutions, this is one time I'm glad I found a decent alternative. One case that comes to mind is collapsible trees and dropdown b…

Note that it's not yet supported by Edge: https://developer.microsoft.com/en-us/microsoft-edge/platfor...

Re: Why is collapsing a Hacker News comment so slow?

#30

I cannot visually notice any delay. It seems instantaneous in my browser.

Same. I am really picky about performance, and I've never seen anything but instantaneous response from collapsing comments. I just tried it right now on a few example threads from the home page and confirmed that it's instantaneous. I would estimate less than 50ms. I can rapidly click a + and - and collapse/expand a comment tree more or less as fast as I can click (the limiting factor being that my browser wants to select the + button itself as text).

For whatever it's worth, I use Firefox on Windows. But I just fired up Chrome and gave it a test, and I see the same thing there. But I don't do a whole lot of HN comment browsing on my mobile device, so I suppose that's the difference.

Post reply on HN