Live data from Hacker News

Vanilla JS, fast, lightweight, cross-platform framework

vanilla-js.com

21–30 of 134 posts

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

#21
post #18
post #16

Earlier quoted context omitted.

jQuery API is not pretty

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.';
  });

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

#22
post #18
post #16

Earlier quoted context omitted.

jQuery API is not pretty

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

The jquery version is easier to write, and less prone to error, but in the native version it's much more clear what's actually going on.

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

#23
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 .

If you're only targeting modern browsers (latest Chrome/FF/Opera/Safari, IE10), is this still true? I was under the impression the recent browsers were standards-compliant enough that you could use vanilla JS.

Of course, most developers still have to target older browsers, but for a private Web app where you know your target audience, this shouldn't be a huge issue.

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

#24
post #2

http://vaporjs.com/ is way better, and was here first.

I prefer semicolon.js, more secure and reliable :) https://github.com/madrobby/semicolon.js

doesn't minify or gzip at all - talk about code golf. does it lint?

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

#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 Simpsons that points and goes "ha-ha!" There's no content. We can't have a discussion around a smartass joke like this.

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

#27
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.'; });

Nope:

TypeError: document.getElementsByTagName("p").filter is not a function

Because you don't get an array, only something array-like.

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

#28
post #22
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!

The jquery version is easier to write, and less prone to error, but in the native version it's much more clear what's actually going on.

Also in the native version, you know you're only doing the work required. The jquery one will be doing a lot of extra useless inefficient grunt work to achieve nothing. Making it incredibly slow in comparison.

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

#29
post #18
post #16

Earlier quoted context omitted.

jQuery API is not pretty

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

This enumeration is done the wrong way. You enumerate over a DOM node list which looks like an array, which includes enumerable properties like "length". This means that the variable "p" at some point will be "length" and "length".innerHTML = "..." will produce an error.

The proper way is:

for( var i=0, ps=document.getElementsByTagName('p'), len=ps.length; i < len; i++) {ps[i].innerHTML = 'Hello.';}

Post reply on HN