Live data from Hacker News

The Single Piece of JavaScript on HN

blog.watchandcode.com

81–90 of 195 posts

Re: The Single Piece of JavaScript on HN

#81
A few weeks ago I turned off javascript in my browser out of principle and to see if progressive enhancement was still a thing web developers cared about (hint: it's not). I was pleased that HN worked fine, and the only annoying thing was that voting caused a page reload. It's nice to see this get the attention it deserves!

Developers! You probably don't need javascript to achieve 90% of your goals. It will just slow your page load speeds.

Re: The Single Piece of JavaScript on HN

#82

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…

For the majority of cases that I've seen, these arguments are simply excuses to avoid doing real work. It's way more fun to decide whether your amazingly awesome Unicorn startup is going to use React or Angular, or Express vs. Rails, or whatever than it is to actually go through the hard work of building a customer base and making money.

This week's JavaScript flavor special is vanilla.

Re: The Single Piece of JavaScript on HN

#83
post #8

Not much to say, really. Just some simple code. What I'm curious is if someone can reiimplement this without and javascript.

It already does work without javascript.

Or do you mean is there a way to asynchronously vote and hide the voting arrows without a page reload?

Re: The Single Piece of JavaScript on HN

#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, visible only to her.

Re: The Single Piece of JavaScript on HN

#85
post #81

A few weeks ago I turned off javascript in my browser out of principle and to see if progressive enhancement was still a thing web developers cared about (hint: it's not). I was pleased that HN worked fine, and the only annoying thing was that voting caused a page reload. It's nice to see this get the attention it deserves! Developers! You probably don't need javascript to achieve 90% of your goals. It will just slow…

But they need it to keep their job :p

Re: The Single Piece of JavaScript on HN

#87
post #74
post #66

Earlier quoted context omitted.

Now I see you are downvoted. I thought your comment was humourous which is always alright to me. In My Humble Opinion downvotes are given out a little too easily here (OK, I'm ready for more downvotes). I hope when I get the downvote ability I will use it wisely, not that many aren't wise.

Downvotes aren't worth worrying about on Hacker News, nor are upvotes. They do tend to even out in time so that only the really objectionable comments get downvoted a lot (and eventually flagged) but because pg more or less decided that there didn't need to be a standard for either, I treat them as worthless.

No point in having a standard you can't enforce.

Re: The Single Piece of JavaScript on HN

#88
post #69
post #60

Earlier quoted context omitted.

That would make the whole downvote system useless. Just post spam comments everywhere then delete them after a day and you’ll always have a positive karma.

Ok, I"m facing an armageddon of downvotes but why the heck was this downvoted? He made a point, that while arguable, is a valid comment. Maybe the discussion of downvoting is bringing more downvotes. Jeeez. Edit: My upvote brought him back to zero, for now.

It may be because this whole discussion is off-topic and not very productive.

Re: The Single Piece of JavaScript on HN

#90

function hide(id) { var el = document.getElementById(id); if (el) { el.style.visibility = 'hidden'; } } function vote(node) { var v = node.id.split(/_/); var item = v[1]; hide('up_' + item); hide('down_' + item); var ping = new Image(); ping.src = node.href; return false; }

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…

[deleted]
Post reply on HN