Tuesday, October 13 2015 9:07 PM
Do we need (a discussion about) jQuery?
Author: matthias - Last modified: Tuesday, October 13 2015 9:35 PM
Discussions about the role of jQuery bubble up these days. Paradigms change, not at least triggered by concepts (re-)introduced with React, Flux and redux. Should we try to avoid jQuery and direct DOM manipulation if possible? I'm not sure, but I want to share some thoughts I had reading a thread titled "Stop say You Don't Need jQuery" in the JS group of linked.in.
No doubt jQuery helped all of us in rapidly developing beautiful cross-browser UI features. No doubt either that it's pretty easy to write messed up code with jQuery, especially when your project is about to grow quickly... It's a question of time & budget, developer skills, performance considerations and of course your individual project needs: Every situation needs the right technologies, patterns, tools, libraries, frameworks, "sandbox areas" and ideas of how all of this can stay maintainable and subject to be refactored frequently. Always keep in mind that a growing codebase is hard to test if it's "hacked"!
If some of your project needs are perfectly covered by specific jQuery plugins – is it okay to start developing with that now? I think: Yes. If criteria stated above is fulfilled.
Think of an application/project you start developing using jQuery today. My advices:
- Write code that people can quickly understand, that you understand when returning to it one year later.
- Use either a well supported framework with a bright community or even write Vanilla JS, but add structure by following some architecture pattern.
- Separate concerns, don't leave people alone with $.callback(hell) spaghetti code!
- Let $.magic() only do the magic!
Then, maybe in 2016, there's this absolutely cool way of integrating and developing rich UI features by just using that awesome new "React Declarative Decorator Dynamite" ES2016 mixin style stuff... You'd probably like to move your code base towards it without rewriting everything, right? You don't? Ah, come on, then just write down jQuery code like it comes to your mind... ;-)
By the way: Did I mention React? Ever tried Flux or even redux?