Live data from Hacker News

The Single Piece of JavaScript on HN

blog.watchandcode.com

191–195 of 195 posts

Re: The Single Piece of JavaScript on HN

#191

Earlier quoted context omitted.

There's a bookmarklet: https://hnlivecomments.pex2.jp/

How is this usable on mobiles? And... Why do I have to rely on a piece of third-party software in order to get features present in any really modern website?

I think HN tries to avoid being too modern...

Re: The Single Piece of JavaScript on HN

#192
post #164

Earlier quoted context omitted.

But it is idempotent in this case. The server keeps track of your votes, so regardless of the number of times you do the same GET, the result is the same.

At the moment, but in the future the browser might decide to prefetch the pages behind these links, hence voting against your will. > (...) we may expand link prefetching support to include prefetching tags, which include a relation type of next or prefetch in the future. Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefe...

Hopefully the HN voting links never contain relation types which would imply prefetching! I recall that Firefox did some aggressive prefetching in the past, and some websites (maybe Wolfram?) temporarily blocked IPs which did the prefetching due to the extra load they were putting on the servers. It's very dicey, requesting URLs for a user which would have a low probability of being followed. Certainly, requesting tens or hundreds of URLs from a single HN page would be a reportable bug for either the browser (for wasting resources) or the site (for misrepresenting hyperlink attributes).

Regardless of all of this, if the HN server filters out duplicate votes, then the idempotence (is that a word?) of the request is satisfied, and it is OK to be a GET. [EDIT: after reading https://news.ycombinator.com/item?id=11308231 my point here is probably invalid, because voting is not a "safe" method. Voting alters the order of posts that future readers see, which is a material change for a discussion site. In contrast, something like a YT view-count tally doesn't effect a material change in the core material.]

Regardless of that, IMHO a GET request that changes the "fundamental" state of the world (not just UI state e.g. pagination/settings) is somewhat "rude" to begin with, because of the common expectation that GET requests are "harmless" and POST requests can change things. But like, that's just my opinion, man.

Re: The Single Piece of JavaScript on HN

#193
post #189

Earlier quoted context omitted.

Why compare the margins of nonsense (lisp and php)? If a site like this were written in Node.js and with mobile users in mind, it would be in all means superior to what we see right now. And right now I see yellow outline around this textarea, which is WebKit's default and they didn't even bother to remove it to make this textarea look the same in all browsers, let alone adapt it for mobiles.

I'm implying that language elitism and faux-intellectual posturing are among the reasons this community seems to correlate the simplicity of the layout with its own intellectual purity. That same elitism would cause the same community to dismiss the same site out of hand, were it written in a language it was popular to hate. But yes, it could be written in any language and still have a more progressive layout, and pe…

Now I get the picture and totally agree. For me, even this yellow outline is a sign of totally ignoring real-world user needs.

Re: The Single Piece of JavaScript on HN

#194

Earlier quoted context omitted.

What's most fascinating to me about this isn't the simplicity, it's that this code has lived for so long with almost no changes. It's a great counter-example to all the recent articles about JavaScript fatigue. It's good for us to see real examples of sites that aren't caught up in the framework of the week hype. At the end of the day we're trying to make stuff that works. ES5 vs ES6, React vs Angular vs. Ember vs. A…

Lol. For hiding a voting arrow after it's clicked. Yes, you're right. You don't need any of that stuff. But if you were to write an entire app in the style of those two functions, things would fall apart. That's not even a hypothetical, it's been proven over and over again that it doesn't work. How is everyone agreeing with you? Is there that much JS fatigue that we're looking at the equivalent of a horse-drawn carri…

How would things fall apart, exactly? On my home machine I browse with NoScript turned on by default, and it's rare that I find a site which is broken badly enough to notice which I still care about strongly enough that I bother clicking "allow". I don't think that most of what people do with JavaScript in the browser needs to be done at all if you filter the motivations of investors and advertisers out of the picture.
Post reply on HN