Thanks for sharing this nice bit of code; we always learn from examples, we should see more of this. I feel the naming is too short, things are just a little too specifically compact and slightly cryptic ... almost like the author is trying to say something ... I've never said this before about code ... but I think that code is 'smug'! Like odd facial hair, or one of those valley-specific t-shirts ... the code trying…
How true hackers write JavaScript
71–80 of 342 posts
Re: How true hackers write JavaScript
#72But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.
Re: How true hackers write JavaScript
#73Thanks for sharing this nice bit of code; we always learn from examples, we should see more of this. I feel the naming is too short, things are just a little too specifically compact and slightly cryptic ... almost like the author is trying to say something ... I've never said this before about code ... but I think that code is 'smug'! Like odd facial hair, or one of those valley-specific t-shirts ... the code trying…
remClass -> does it hurt to write removeClass ?
what is vis, ind, posf? I shouldn't have to decipher the function to figure out what its name might mean.
Hacker? no. Smug? yes
Re: How true hackers write JavaScript
#74function hidestory (ev, el, id) { for (var i=0; i That 3 there is the problem with “simple” JS. It’s tightly coupled to the HTML but they live in completely different places. On a side note this 3 should be at least assigned to a variable with a meaningful name.
Re: How true hackers write JavaScript
#75Re: How true hackers write JavaScript
#76Re: How true hackers write JavaScript
#77Re: How true hackers write JavaScript
#78Earlier quoted context omitted.
For the record, jQuery 3.3.1 (production, normal) is at 30kb [1]; if you don't want effects (production, slim), you can get it for less than 24kb [2]. For the value it provides, that does not sound "too big" to me. [1]: https://code.jquery.com/jquery-3.3.1.min.js [2]: https://code.jquery.com/jquery-3.3.1.slim.min.js
In contrast, hn.js only weighs 2.1kb and contains all the business logic.
Re: How true hackers write JavaScript
#79The authors is quite lazy or cannot type fast enough, so he has to create all those cryptic abbreviations: `rks` for `ranks`, `unv` for `unvote`, etc. Which makes it really hard to read. But it's especially the inconsistent use of camelcase in function names than makes me think it's pretty amateurish.
Re: How true hackers write JavaScript
#80Some examples:
The functions hasClass, addClass, and remClass could be replaced by Element.classList [0].
Another one is remEl, which can be replaced with a direct call to ChildNode.remove() [1].
I was going to give more examples, but I don't feel like rewriting the whole script.
[0] https://developer.mozilla.org/en-US/docs/Web/API/Element/cla...
[1] https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/r...