Live data from Hacker News

Why is collapsing a Hacker News comment so slow?

github.com

51–60 of 123 posts

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

#51

> 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?

Yes, but you need a token to log out. For collapsing comments it should work though

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

#52
post #2

That is really ugly code.

For me HN is a great reminder that done is better than perfect.

I definitely agree with that. If you look at how HN does any individual thing, it's almost always "wrong", but it really doesn't matter. It's become (and stayed) a thriving community for over 10 years anyway, and almost nobody knows or cares how any of it works.

My favorite example is probably how the "AJAX" voting works: when you vote, the Javascript creates a new tag with the src= attribute set to the vote endpoint, so when the browser tries to load that "image" it does a background request.

It's the kind of dirty hack that hasn't been necessary for an extremely long time and could be replaced with a proper method in minutes, but nobody even notices that's how it works.

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

#53
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?

> If you want this behavior why not use local storage instead?

My guess would be that the decision was made before a standardized, widely available cross-browser implementation of localstorage was a thing.

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

#55

Earlier quoted context omitted.

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

There's a handy polyfill for that. https://github.com/rstacruz/details-polyfill

Yeah I was going to say, I'm sure the polyfill shouldn't be entirely horrible...

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

#56
post #8

Earlier quoted context omitted.

For me HN is a great reminder that done is better than perfect.

More like, "It kinda works, we don't give a crap".

Yep, and they could easily find volunteers to improve the site (make the login page look nicer, maybe even implement 2fa) but there's no incentive to improve

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

#57

Earlier quoted context omitted.

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

Yes, but you need a token to log out. For collapsing comments it should work though

correction: same origin policy, so it doesn't work

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

#58
post #34

Earlier quoted context omitted.

Edge is turning into Chromium soon, so that shouldn't be a problem for much longer.

Considering there are millions of people still using IE11, I'd say it will continue being a problem for a long time. 18% of my users are on IE11. Some industries (healthcare, for example) don't change if they don't perceive something to be broken.

Doesn't Edge auto-update though? How easy would it be, as someone in enterprise IT, to keep users on an old version of Edge?

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

#59
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?

I looked into using to handle collapsing comment threads on Tildes, and ended up deciding it wouldn't work well and just went with JS.

It was a long time ago now so I can't remember much specifically any more, but I think that the styling and behavior for were both too limited and too inconsistent across browsers.

I do use it in some other places though, like collapsing/expanding the text of text topics from the listing pages, and it works really well for that (other than the current lack of support in Edge).

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

#60
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?

Persisting it on the server allows users to browse on multiple devices and keep their collapse settings in sync. This is useful in particular for long threads of comments, where collapsing can be used as a tool to keep track of progress through the thread by collapsing comments along the way.

That sounds like a solution in search of a problem tbh
Post reply on HN