Live data from Hacker News

Why is collapsing a Hacker News comment so slow?

github.com

91–100 of 123 posts

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

#91
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…

with get you can also have multiple inserts when some network things break. because get requests might be retried.

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

#92
post #66

Earlier quoted context omitted.

> If it's your own server you can do whatever you want. This is not at all true. For example, say I'm a user in a dorm that uses a proxy that I have no control over. If you make your GET request modify things, that proxy may cache the request, or worse, may repeat the request later to maintain its cache. My point is, you don't know what is between your server and their client, and even well behaved infrastructure wil…

It's also an issue when you don't even fully control the client, which in this case is the web browser. A game at least behaves exactly as you program it. Browsers are not necessarily consistent, especially when you throw in extensions.

Yes excellent point. Some browsers/plugins will prefetch every GET on the page to speed up browsing.

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

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

Didn't know about . I was actually working on a site that uses threaded comments recently, so I might consider using it.

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

#94
post #2

That is really ugly code.

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

Done is only better than perfect because you can't have perfect.

You can still often have better than done, though. The first working implementation is rarely the best possible one.

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

#95
post #90
post #39

Earlier quoted context omitted.

It's really only an issue on mobile when you're collapsing larger threads. Try collapsing the first comment in this thread, for example: https://news.ycombinator.com/item?id=14656945 Not terrible, but there's a noticeable (maybe ~1 second on my phone) delay. My desktop is fast enough that it still feels instant.

One answer to this is to paginate long threads so there's a definite upper limit to the length and depth of the thread on any page.

this is a bit ridiculous... folding a few thousand lines of plain text should be fast no matter what. If it isn't, then there's something quite wrong.

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

#96
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".

That's not nice. I don't mind if you diss our code. But I do mind if you say we don't give a crap.

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

#97
post #90

Earlier quoted context omitted.

One answer to this is to paginate long threads so there's a definite upper limit to the length and depth of the thread on any page.

this is a bit ridiculous... folding a few thousand lines of plain text should be fast no matter what. If it isn't, then there's something quite wrong.

I don't want to knock dang or whoever wrote it but when I look at HN's JS it looks to me like it was written more to resemble Lisp idioms and to look elegant than to be efficient. If so, that may just be someone working in their comfort zone, which is fine - it works, and if it were much more complex than it is, HN being HN would complain. It's not bad, it just doesn't scale.

Also, I suspect but don't know that the table based layout makes showing and hiding elements a lot slower than it would be with, say, divs or an unordered list. If this is the case, it would probably only be exacerbated on mobile.

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

#98
post #67

If you don't mind me being negative here for a moment: 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. 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 r…

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

1) This is a community with a lot of web developers and programmers, and people who have a professional or hobby interest in these problems, and are hanging out here anyway clearly with nothing better to do.

2) We have to do it here because they don't take issues and pull requests.

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

#99
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 would also question why we are saving collapsed comments.

I can't be the only one who had no idea it did this? And if so, I'd could argue that there isn't really a need for it.

Post reply on HN