You Don't Need JQuery
blog.garstasio.com
You Don't Need JQuery
1–10 of 201 posts
Re: You Don't Need JQuery
#2Re: You Don't Need JQuery
#3Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not because of DOM manipulation, as long as you're willing to sacrifice simplicity and readability, you can build iterative loops to modify a collection of HTML elements.
No, it's the unexpected things that cause me pain. Want to use event handlers on dynamically generated DOM objects? Write your own event bubbling library. Want to create custom events/handlers? Ditto. Promises, .serialize(), .extend(), etc. might all be simple to write your own version, but when you realize you've reimplemented 50% of jQuery to avoid using jQuery, you feel like an idiot. [Source: I do this every 3 years]
Life is too short to not use jQuery.
Re: You Don't Need JQuery
#4I think a lot of the issues people have with jQuery is that (as the article mentions) it's become synonymous with Javascript and abstracts so many things that many people using it don't understand the underlying framework and functions. That and why include more resources if you don't really need to.
Re: You Don't Need JQuery
#5(Sorry ;))
In all seriousness I'd recommend watching Adam Sontag's keynote from jQuery UK 2014 which covers the "not needing" jQuery stuff http://vimeo.com/97723665
Re: You Don't Need JQuery
#6Every time I try to build something without jQuery, I regret it. Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not because of DOM manipulation, as long as you're willing to sacrifice simplicity and readability, you can build iterative loops to modify a collection of HTML elements. No, it's the unexpected things that cause me pain. Want to use event handlers on dynamically gene…
Re: You Don't Need JQuery
#7 $('#foo').removeClass('bold');
vs. document.getElementById('foo').className =
document.getElementById('foo').className.replace(/^bold$/, '');
The author summarises this, helpfully: "As usual, more characters, but still easy without jQuery."Of course, if you were doing that remove class operation quite often, rather than writing all that code out each time, you might wrap it up in a helper method, and maybe you'd call it, I don't know, "removeClass" or something; perhaps if you were doing a whole bunch of DOM operations you might create little helper methods for each one, again to save you some typing. Pretty quickly you might end up with a little library of helper methods... and, of course, being a wonderful programmer who never makes mistakes, I'm sure that little library would be every bit as optimised, reliable, and correct as a battle-tested library used on hundreds of thousands of web sites.
Re: You Don't Need JQuery
#8Every time I try to build something without jQuery, I regret it. Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not because of DOM manipulation, as long as you're willing to sacrifice simplicity and readability, you can build iterative loops to modify a collection of HTML elements. No, it's the unexpected things that cause me pain. Want to use event handlers on dynamically gene…
Life isn't always a hipster website where people can get lunch delivered on their phone or whatever. Things like jQuery are fine.
Re: You Don't Need JQuery
#9Re: You Don't Need JQuery
#10If you're developing a single page application, you only load jquery once, then do the rest with AJAX calls for JSON and assets. It's worth the <100 KB on initial page load, at least for the projects I've worked on.