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..
Vanilla JS, fast, lightweight, cross-platform framework
31–40 of 134 posts
Re: Vanilla JS, fast, lightweight, cross-platform framework
#32Earlier 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.'; });
Array.prototype.forEach.call(document.getElementsByTagName('p'), function(el) { el.innerHTML = 'Hello.'; });
Re: Vanilla JS, fast, lightweight, cross-platform framework
#33Re: Vanilla JS, fast, lightweight, cross-platform framework
#34Fast 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
Re: Vanilla JS, fast, lightweight, cross-platform framework
#35Recently, 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.
Re: Vanilla JS, fast, lightweight, cross-platform framework
#36Fast 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
Re: Vanilla JS, fast, lightweight, cross-platform framework
#37Re: Vanilla JS, fast, lightweight, cross-platform framework
#38I 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…
Re: Vanilla JS, fast, lightweight, cross-platform framework
#39I 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.