I have seen this library in the recent courses I've taken. Playing around with vanilla JS I really found it useful!
However, I've seen lots and lots of posts dismissing the use of Jquery, probably in favour of the use of a fancy new framework as React or VUE.
But I found these opinions very drastic and non-newbie friendly. Starting with a framework is medium-advanced stuff that maybe not everybody is ready for.
What do you think?
Latest comments (20)
Absolutely, vanilla JS is best practice for creating great stuff. Jquery is for noobs. :)
I've been a software developer for 30+ years, FullStack... JQuery is for Both Newbies and Seasoned Developers... It's all about picking the right tools for the project and clients current Ecosystem. React, Angular, Vue, Node.js, Go and yes jQuery, PHP, Java might be the right tool to select from your toolbox.
Kinda my point else where though. You need to learn about DOM manipulation. You can just use fetch now for learning AJAX stuff (if you need something better supported than fetch you can grab axios, but I would still use fetch for learning purposes), and your animations should not rely on javascript now days. I would never point to a front end frame work until there is a solid understanding of HTML, CSS and JS in place. And that absolutely includes DOM manipulation. JQuery was a savior back in the day, when DOM traversal was implemented differently by each browser, animations relied heavily on javascript, and you had to write xhr requests (though xhr isn't THAT bad once you make yourself do it a few times). But all the things Jquery solved aren't really issues anymore...
If it's a quick throw away thing, sure no problem. If this is a big application, and it's 2019, Jesus, shame on you.
No it's not. jQuery is still a great tool.
Certainly you can just use vanilla and save some 1.5kb of traffic usage.
No. The use of jQuery in itself is not bad practise.
Many of the comments on here are ignoring the real world scenarios where institutions such as banks and government agencies still use out of date browsers with special paid support from Microsoft because their whole infrastructure is based around the use of older versions of Internet Explorer. In these cases you definitely cannot consider the user of jQuery bad practise because it is more consistent than the browsers own apis in msot cases. Yes, if you are developing anything for modern browsers then you should consider something like Vue or React for future proofing but if you need to put a simple site out there without the overhead of learning one of these new framework / libraries and you already know jQuery then there is no harm in starting a project using jQuery with the aim of porting over to one of the hot frameworks later on or indeed using Vanilla JS. The big issue here is programming snobs. The people who want to move on to the latest, hottest, "greatest" framework without looking at the overall implications such as the time required in order to ensure that stuff is implemented correctly with a team who has not used it before. My advice, ignore these snobs. Learn the newer frameworks in your own time. In fact, learn just one. Most of the principles carry over. In the meantime use what you are comfortable with and can be most productive with.
I think there's historically been a window where jQuery is useful, and outside that window it's either redundant or starts causing problems.
If your application has around two or three hundred lines of Javascript, not including third party libraries, then jQuery is sufficient. As you go past that point, it starts getting harder and harder to organize your code, and you approach the point where something like React or Vue would be a better fit. It's not impossible to organize jQuery code properly, but it's a chore and is far less natural than with React, so you tend to build up technical debt. The legacy application I inherited pushed far beyond the point where you should look elsewhere, and the Javascript is a nightmare - when you add an already defined class to an element, you're apt to find it suddenly gains some unwanted functionality. I've started migrating it to React, but it's going to be a long job.
At the lower end, there's also less need for jQuery at the bottom end of that window. Due to better CSS and JS support in browsers, much of what it does simply isn't needed anymore. So that window of usefulness is getting smaller. With Bootstrap 5 planning to drop jQuery as a dependency, there will be even less need to include it.
For non SPAs (where you might prefer React/Vue/etc) it still has very convenient features.
Um... your third point about jquery ajax does more than fetch isn't correct. fetch is a surprisingly low level api and you can absolutely set any header you want...
Sure I meant by default without any settings.
I think jQuery was great back in the day for all the reasons that have already been stated.
That said, if I were to guide a complete newbie, I would tell them to avoid jQuery and only focus on JavaScript. I say this because while it may seem easier to get started with jQuery I feel it will hinder your progress and can essentially throw you into a world of JavaScript without really understanding the fundamentals of it. That goes for any lib or framework, if you put the time in to learn native JS you will be far better off in 6 months time than if you used a "jump start" tool like jQuery.
I agree on the first point, you don't need any framework to learn Javascript, actually it would be better to learn React or Vue after you have a solid knowledge of Javascript and ES6, so most of the "magic" those frameworks provide is easily understood.
I don't agree on the second point though, jQuery was absolutely needed because browsers (IE mostly) didn't have a consistent API, and making something work across all devices was a nightmare( just think about manipulating classes before HTMLElement.classList was introduced). Nowadays on the other hand, every modern browser has a basic set of DOM features that don't need normalization, and using jQuery is the same as using React or Vue: you are using an abstraction on top of the standard API, but while React and Vue offer something more than just a DOM abstraction, jQuery stops there. It's true that some APIs are more friendly in jQuery, but you just end up loading an external dependency for commodity
You can't compare those.
jQuery is mostly a compatibility layer on top of shitty browser APIs. Turns out things evolved since IE6 and you might not need jQuery (nor anything else).
Now if you want to make non-trivial front-end interactions then you'll find that a framework like Vue helps a lot. Because it will render a state into DOM, you don't need to worry about cleaning up things all the time. Also, Vue can be inserted progressively into your front-end and does not require any toolchain. It's lighter and more convenient than jQuery to build apps!