> 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?
Why is collapsing a Hacker News comment so slow?
51–60 of 123 posts
Re: Why is collapsing a Hacker News comment so slow?
#52That is really ugly code.
For me HN is a great reminder that done is better than perfect.
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?
#53I 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?
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?
#54Re: Why is collapsing a Hacker News comment so slow?
#55Earlier 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
Re: Why is collapsing a Hacker News comment so slow?
#56Earlier 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".
Re: Why is collapsing a Hacker News comment so slow?
#57Earlier 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
Re: Why is collapsing a Hacker News comment so slow?
#58Earlier 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.
Re: Why is collapsing a Hacker News comment so slow?
#59I 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?
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?
#60I 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.