Live data from Hacker News

Vanilla JS, fast, lightweight, cross-platform framework

vanilla-js.com

31–40 of 134 posts

Re: Vanilla JS, fast, lightweight, cross-platform framework

#31
post #18

Earlier quoted context omitted.

I'll take $('p').text('Hello.') over for (var p in document.getElementsByTagName('p')) { p.innerHTML = 'Hello.'; } any day!

innerHTML is an easy one, try setting an attribute -- you have to create a new attribute node, set its value and then add that to the element..

setAttribute()?

Re: Vanilla JS, fast, lightweight, cross-platform framework

#32
post #21
post #18

Earlier quoted context omitted.

I'll take $('p').text('Hello.') over for (var p in document.getElementsByTagName('p')) { p.innerHTML = 'Hello.'; } any day!

did you ever try to debug your pretty jquery karate? ps. second example is not valid, in Vanilla JS you do it like this: document.getElementsByTagName('p').filter(function(el) { el.innerHTML = 'Hello.'; });

The right way is this :)

Array.prototype.forEach.call(document.getElementsByTagName('p'), function(el) { el.innerHTML = 'Hello.'; });

Re: Vanilla JS, fast, lightweight, cross-platform framework

#34
post #16
post #9

Fast and lightweight, yes. But vanilla-js is certainly not cross platform ;) You see, that's actually one of the biggest problems with JS and one of the main reasons why people use things like jQuery (apart from the pretty API..). That cross platform bit is the weakest link sigh .

jQuery API is not pretty

[deleted]

Re: Vanilla JS, fast, lightweight, cross-platform framework

#35
post #10

Recently, I was interviewing a front-end developer candidate and I gave them a simple JavaScript problem. The sad thing was, they didn't recognize `document.getElementById()` and didn't know any of the parameters to `addEventListener()`. We finished the exercise assuming the example used jQuery instead.

maybe I'm mistaken, but I think this is more of "jquery programmer" problem. jQ really abstracts away from the nitty gritty of the dom api and also for any beginner / intermediate frontend guys the source is not very readable. In comparison dojo for example, requires you know what you're doing and also to have pretty extensive knowledge about js, the dom, etc. Also, in my opinion, its source code is very clean in comparison.

Re: Vanilla JS, fast, lightweight, cross-platform framework

#36
post #16
post #9

Fast and lightweight, yes. But vanilla-js is certainly not cross platform ;) You see, that's actually one of the biggest problems with JS and one of the main reasons why people use things like jQuery (apart from the pretty API..). That cross platform bit is the weakest link sigh .

jQuery API is not pretty

I am a c developer, now I want to learn jQuery , but its syntax seems so weird to me, Vanilla JS looks more comfortable to me , one questions, does it supported by webkit?

Re: Vanilla JS, fast, lightweight, cross-platform framework

#38
post #25

I can't be the only one getting tired of sites like this making the front page. Really? It would be one thing to see someone write a legitimate article on why they think the move to JS frameworks is harmful and/or the benefits of using plain JS, and for that to make it to the front page. I'd be interested in that perspective. But this is just somebody being snide. It's the internet equivalent of the kid on The Simpso…

If you'll look at the comment below, you'll see a rather interesting discussion going on. Jokes can be an effective way to start a dialogue.

Re: Vanilla JS, fast, lightweight, cross-platform framework

#39
Ops/sec is a great way of benchmarking hardware and interpreters but is a poor way of rating framework vs no framework performance and usefulness.

I get the point, you might not need a JS abstraction in modern browsers for some things, but the trade-offs for not being able to reference 12 million dom nodes per second are pretty substantial.

And extending these frameworks usually happens in a pretty standard and predictable way which is super useful.

TLDR: I'll keep this in mind next time i need to reference 12 million dom nodes in one second.

Post reply on HN