News for hackers. Stuff that matters.
Re:Tell HN: Thank you for not redesigning Hacker News by ezequiel-garzon on Sunday September 01, 2019 @04:52PM (#20854809)
I assume you have JavaScript disabled, right? If so, can you give an example of a similar webpage that doesn’t reload the whole page to reflect your vote?
Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Sunday September 01, 2019 @08:32PM (#20855887)
You're correct that when JS is disabled, any interaction requires a HTTP request from a link or form, and that does a full page reload.

However when JS and AJAX is used, it's expected that it also avoids an entire full-page HTML response that goes unused. It can easily be a 204 instead.

Re:Tell HN: Thank you for not redesigning Hacker News by jakeogh on Monday September 02, 2019 @05:14AM (#20857805)
Can't frame tags reload independently?
Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Monday September 02, 2019 @04:00PM (#20861430)
It's still a full page refresh but with a page within a page. Making every comment a separate iframe would make the site very resource intensive on client and server.
Re:Tell HN: Thank you for not redesigning Hacker News by jakeogh on Monday September 02, 2019 @06:07PM (#20862084)
I dont see why it would be resource intensive server side. In fact, it would be less resource intensive, since we avoid a full page reload and instead reload a single comment iframe.

As for the rendering engine, a iframe tag per comment is nothing compared to the pile of JS that's normally there on other sites.

Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Monday September 02, 2019 @06:35PM (#20862209)
Every frame is still a full HTML document that needs to be generated even if it just contains a single comment. This page has 370+ comments which would mean 370+ additional HTTP requests to load them all as standalone HTML pages. That's a massive increase in server load.

On the client, iframe tags are entirely separate browser windows and can use up considerable resources. It's like opening up hundreds of tabs and is far more intensive than running some javascript code which is quickly parsed, compiled and cached in modern JS engines.

Re:Tell HN: Thank you for not redesigning Hacker News by jakeogh on Monday September 02, 2019 @07:02PM (#20862349)
Ah. Thanks. Understood. I often wonder if one could whitelist a very small subset of JS and avoid Turing Completeness but enable 90% of the use cases.
Re:Tell HN: Thank you for not redesigning Hacker News by nothrabannosir on Sunday September 01, 2019 @08:04PM (#20855796)
No this is about JS enabled. It's the same endpoint. Open dev console and have a look.
Re:Tell HN: Thank you for not redesigning Hacker News by segfaultbuserr on Monday September 02, 2019 @05:35AM (#20857890)
I can confirm. Just upvoted your comment with JavaScript enabled, still has 10 KiB transfer.
Re:Tell HN: Thank you for not redesigning Hacker News by Deimorz on Sunday September 01, 2019 @04:57PM (#20854839)
No, voting doesn't work at all with JS disabled.
Re:Tell HN: Thank you for not redesigning Hacker News by icebraining on Sunday September 01, 2019 @05:18PM (#20854980)
Yes, it does. I think you have something weird with your browser: with JS on, it does a light AJAX request, without it, it does the whole redirect thing.
Re:Tell HN: Thank you for not redesigning Hacker News by manigandham on Sunday September 01, 2019 @06:10PM (#20855322)
The request is the same. The buttons are <a> tags. Without JS, the link is clicked and does a full page reload. With JS, the click is caught and sent as a AJAX request where the response is ignored.

It's not any lighter, it's just not reloading the page.

Re:Tell HN: Thank you for not redesigning Hacker News by oplav on Sunday September 01, 2019 @05:37PM (#20855113)
https://i.imgur.com/9z2VAfa.png

These are my network requests when I vote with JS enabled.

Re:Tell HN: Thank you for not redesigning Hacker News by Deimorz on Sunday September 01, 2019 @06:39PM (#20855481)
Whoops, you're right, it does work either way. The response is the same with or without JS though, it just doesn't do anything with it when JS is enabled (because as a hacky way of doing "AJAX" it sets the voting url as the src value of an <img> tag that doesn't actually get displayed).
Re:Tell HN: Thank you for not redesigning Hacker News by cynwoody on Sunday September 01, 2019 @11:39PM (#20856617)
Voting does work with JS disabled, just not well.

The page reloads and re-renders with the UI changes (up-down buttons hidden and unvote link added). However, the reload takes noticeable time, and you lose your scroll location, which is disorienting.

With JS enabled, the UI changes happen instantly, and the scroll position doesn't change. The page still reloads, but the reload is directed into a new Image object which is immediately garbage, so it's off the UI timeline. But it's inexplicable bandwidth waste, nonetheless!

Re:Tell HN: Thank you for not redesigning Hacker News by crispyporkbites on Sunday September 01, 2019 @05:05PM (#20854892)
You can do this without javascript, you just create a form that sends an XHR PUT/POST request and returns back a 200 response.

You can't do much with the response without JS but a single upvote doesn't change anything on the page so there's no need for the reload.

Re:Tell HN: Thank you for not redesigning Hacker News by icebraining on Sunday September 01, 2019 @05:20PM (#20854990)
> a single upvote doesn't change anything on the page

Not much, but it does hide the arrows and shows an undo link on the comment.