Live data from Hacker News

The Single Piece of JavaScript on HN

blog.watchandcode.com

151–160 of 195 posts

Re: The Single Piece of JavaScript on HN

#151

Earlier quoted context omitted.

> HN looks and works great on mobile now (it didn't used to but they did a redesign in the last few months). For the record, after the redesign the comments looks worse on Windows Phone. I know, no one gives a damn about WP, but a "proper" mobile redesign would work on every browser.

Is that the fault of HN or Windows Phone?

HN.

Makes me thinkg of that great rant my Linus about breaking userspace by "fixing" a "bug"

If you break something for a significant portion of your users, even if it's caused by someone/something else doing something dumb, it's still your fault

Re: The Single Piece of JavaScript on HN

#153
post #49

Earlier quoted context omitted.

This code is simple, works reliably and has done so for a long time with no changes. That seems like the opposite of broken to me

But GET requests should be idempotent.

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.

Re: The Single Piece of JavaScript on HN

#154
post #130

Is it just me, or it sounds... cult-ish / overly dramatic? >> it wasn’t obvious to me that Hacker News had any JavaScript at all. I guess he never votes. >> I thought it would be weird and complicated, but it turned out to be quite the opposite. You’ll have to watch the video to see what I mean. Well, it sends a HTTP request and hides an element. How on earth can it be complicated? I mean, ok, you can use The Framewo…

Not just you. I don't see why this warrants a 12 minute video.

I'll give you one reason. I've never done any front-end stuff before. But maybe a month ago, I got curious. Perhaps because I read HN everyday.

And if you try to immerse yourself in the front-end world, you get 'yeah, learn HTML/CSS/JS, BUT, also learn Angular, React, JQuery, et. al...' It's good to get a reminder that Javascript in and of itself is a capable language. I'm sure I'm not the only one in this camp.

Maybe it didn't need to be 12 minutes, and it was certainly more of an 'oh, interesting' than anything, but I'm glad I took the time to watch it.

Re: The Single Piece of JavaScript on HN

#155

If we ever make it around to a second piece of javascript on here, can I request that it be a collapse comment function? I promise i won't ask for anything else.

If you want the state of your collapsed comments to be remembered between session you're adding a lot of data to the backend of HN. I can see not implementing it, because threads are short lived and rarely get more comments that can be reasonably browser or searched.

I don't see that collapsing comments would really add much value, especially if the state is to kept per user per comment in the backend.

If you don't care about state, I feel reasonably sure that you could Greasemonkey your way out of not having that feature.

Re: The Single Piece of JavaScript on HN

#156
post #152

I wish the code had a license. It is easy enough to add a license to inline Javascript so that it is machine-readable: https://www.gnu.org/philosophy/javascript-trap.html#Appendix...

Wouldn't this piece of code be classified as "trivial" by the policy in the link, and therefore not need it?

Anyway, if you download the source and look in the 'copyright' file it says:

"This software is copyright (c) Paul Graham and Robert Morris. Permission to use it is granted under the Perl Foundations's Artistic License 2.0"

http://www.arclanguage.org/arc3.1.tar

(I'd be more worried about the license of the Algolia Search provided on Hacker News. Way more JS there. It's even using AngularJS)

Re: The Single Piece of JavaScript on HN

#157

I see a lot of comments here about how not having js on the page is a great thing and lets get back to the old days. Lets be frank here, HN's UI is not good. At the very least it needs collapsible comments and responsiveness to mobile. The fact that HN is a success is despite its bad UI, or maybe because of the many HN readers out there that fix all the broken stuff on the page. While js on sites have surely overgrow…

Honestly, HN is great, and this:

> At the very least it needs collapsible comments and responsiveness to mobile.

I don't even want that. On root comments, simply add a link (let's call the text "next") that jumps to the next root level comment. That would solve my only complaint about the HN UI.

Re: The Single Piece of JavaScript on HN

#158
post #84

Using this approach, a badly written prefetch add-on might automatically vote on everything. Any request that modifies server-side state really should use POST or PUT (or, at the very least, append a CSRF token in JavaScript). I eventually find this bug on just about every project. One time a user complained that all comments would disappear from her posts. Found that an add-on was prefetching all "delete" links, vis…

Yes, this is an old problem. It came up with early versions of Rails scaffolding, which only used GET at the time. There's no excuse for deleting with GET.

Reminds me of an old story about an internal wiki at a company I once worked. They tried to add a search feature which initially crawled all pages. Once that was done, the complete wiki was empty...

Re: The Single Piece of JavaScript on HN

#159

I see a lot of comments here about how not having js on the page is a great thing and lets get back to the old days. Lets be frank here, HN's UI is not good. At the very least it needs collapsible comments and responsiveness to mobile. The fact that HN is a success is despite its bad UI, or maybe because of the many HN readers out there that fix all the broken stuff on the page. While js on sites have surely overgrow…

To get collapsible comments, you can use "Reddit-Style Comments for Hacker News" chrome extension/GreaseMonkey script: https://github.com/andrewheins/HN-Comment-Hider
Post reply on HN