News for hackers. Stuff that matters.
Re:Tell HN: Thank you for not redesigning Hacker News by zeta0134 on Sunday September 01, 2019 @06:24PM (#20855414)
Okay quick thought exercise. HN doesn't use a react framework and is quite lightweight on clientside JavaScript. How many upvotes does it take using this system before the total data size transmitted (original page + modifications) is, in sum total, larger than a fresh load of, say, Twitter?

The reality is that for the bulk of users, votes are an uncommon interaction; most of us are here to read the articles and view the comments. The additional complexity needed to make votes small has an upfront cost, and in this case, I feel the simplicity of the base interface is the better thing to optimize for, and HN's designers appear to agree. 10 kB for what is effectively a server-side page reload (which probably gracefully degrades for folks running NoScript) seems fine.

Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Sunday September 01, 2019 @08:31PM (#20855883)
It's nothing more than an extra header or query param to denote an AJAX request. Then the server can respond with an empty 200/204 status code instead of the entire HTML page. It's an hour of work and would actually save resources. None of this requires a front-end framework.
Re:Tell HN: Thank you for not redesigning Hacker News by iforgotpassword on Monday September 02, 2019 @03:46AM (#20857434)
No need for custom header or query param, Ajax (xmlhttp) requests already have an extra header field set automatically, so all is needed is some if statement server side, assuming registering the upvote and rendering the page is not entangled in some super crazy way.
Re:Tell HN: Thank you for not redesigning Hacker News by pmarin on Monday September 02, 2019 @02:56AM (#20857241)
HN works perfectly with javascript dissabled. It’s a feature
Re:Tell HN: Thank you for not redesigning Hacker News by IanCal on Monday September 02, 2019 @03:05AM (#20857275)
It can still easily work with JavaScript disabled and implement the change.
Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Monday September 02, 2019 @05:08AM (#20857781)
We're talking about it working better when JS is enabled.
Re:Tell HN: Thank you for not redesigning Hacker News by xur17 on Sunday September 01, 2019 @08:43PM (#20855931)
You'd need some frontend code to hide the upvote icon though.
Re:Tell HN: Thank you for not redesigning Hacker News by Deimorz on Sunday September 01, 2019 @09:14PM (#20856056)
That frontend code already exists and does that every time you vote (line 27 of https://news.ycombinator.com/hn.js). The response content isn't used for anything at all.
Re:Tell HN: Thank you for not redesigning Hacker News by zeta0134 on Sunday September 01, 2019 @10:32PM (#20856368)
Nice! I hadn't actually looked at the code before writing my comment. That does seem relatively trivial, so I stand corrected. I didn't realize the clientside code was discarding the response; I sorta naively assumed it was doing a DOM replacement or something equally straightforward.

What a pleasantly tiny script file. More site code should be this easy to read.

Re:Tell HN: Thank you for not redesigning Hacker News by samtheprogram on Sunday September 01, 2019 @11:59PM (#20856681)
If you have JavaScript disabled, the response content is used to hide the upvote sign.
Re:Tell HN: Thank you for not redesigning Hacker News by TeMPOraL on Monday September 02, 2019 @03:22AM (#20857337)
We're talking here about something simple like:

  (if *ajax-request*
     (upvote)
     (upvote-and-generate-page))
Re:Tell HN: Thank you for not redesigning Hacker News by novok on Sunday September 01, 2019 @06:33PM (#20855459)
But they're already using javascript, and the issue is the backend response, so this would only be a backend optimization then and doesn't require any fancy frameworks?
Re:Tell HN: Thank you for not redesigning Hacker News by pmarin on Monday September 02, 2019 @02:57AM (#20857245)
No, It’s not needed. I have been using it without javascript for years.
Re:Tell HN: Thank you for not redesigning Hacker News by nindalf on Monday September 02, 2019 @03:31AM (#20857369)
You aren’t understanding the person you’re replying to.

No one is contesting that HN can work without JS. But for those who have JS enabled, it uses JS. For these people the optimisation could be implemented.