Why? Libraries make life easier and speed development, stability and maintainability. Larger common ones also mean ease of finding other devs who can work on it instead of custom designed in house stuff.
I did and I see the point but I don’t agree with it. Loading a 90KB library is nothing compared to making a programmer’s life easier and the code simpler IMO.
Did you take a look at the website? I'm aware of all of the vanilla js features analogous to jQuery functionality but it just looks so awful and you can never remember it. If you want to build something fast, you use jQuery. Easy.
I chose jQuery because it’s easy for the project I’m working on. If you’re interested, it’s essentially a social network for scientists. The idea is to make a website where scientists can publish their papers and get paid to do so.
And from my experience, jQuery can be fluid depending on how fast the user’s internet connection is, as well as implementation. I managed to make a one page search engine where all the results are in the suggestion bar using jQuery. It was very fluid.
Modern browsers have way better and more consistent JS support. A lot of the quirks that jQuery was built to work around and smooth over no longer exist in commonly-used browsers, and haven't for some time now. I wouldn't say it's bloat, but it's not an entirely unfair description at this point.
jQuery mantra has always (or at least since 2010) been write less, do more and that's still true today. writing $() is faster than writing document.querySelectorAll(), writing $("foo").on("click",function(){console.log(this.textContent+" clicked");}); is faster than writing
loading jQuery from a CDN (like GoogleCDN, cdnjs, or jsdeliver) is cheap, while developer time isn't cheap. also jQuery is such a popular library that chances are good the browser cache already has it if you use a popular CDN.
also, minified jQuery 3.5.1 is 0.08 megabytes of code, and 0.02 megabytes gzip-compressed
DataTables has so many nice features, but the loading performance has been bad in practice... or maybe it's just the buttload of data I try to load with it.
I prefer to use document.querySelector() and not just because it's newer. The results are more reliable imo. Single item vs document.querySelectorAll() giving as many as it can find. Also I wouldn't need jQuery or require me to think about it's methods.
I generally agree with using document.querySelector (or document.querySelectorAll, depending on what you need), except in the case where I have an ID or a class in a variable and I have to select by just that. In those cases, I find it cleaner to just use document.getElementById or document.getElementsByClassName as appropriate instead of having to do the extra step of building a selector.
I think this is still generally discouraged, though. This has been the behaviour in Web browsers for many many years now, but if I recall correctly, support was added for IE parity. You can run into issues if you happen to have multiple elements with the same ID (which is technically incorrect, but not hard to run into), and over time, this technique can be brittle as new features are added to the spec.
19
u/pagraphdrux Mar 01 '20
What do you prefer?
11
u/froggie-style-meme Mar 02 '20
Use jQuery or gtfo
46
u/HappyViet Mar 01 '20
I don't know much about jQuery yet but Ajax is pretty useful. What's the hate on jQuery? Does it bloat?
13
u/blackadress Mar 01 '20
DataTables gang rise up!!!
Now seriously, any suggestions to replace the datatables in my code, handsontable just doesn't cut it
4
u/lor_louis Mar 02 '20
Anyway anything jquery does PHP can do too.
2
u/SwanX1 Mar 02 '20
I get people who use JQuery, but personally, it's a hassle.
2
u/frejaland47 Mar 07 '20
you meant document.getElementById('i-hate-it') ?
3
u/Holzkohlen Mar 02 '20
jQuery is fine, I just hate JavaScript itself. Garbage language.
1
u/loscapos5 Mar 02 '20
I love jQuery, but i prefer to use other stuff instead.
I mean, You can't just hate on your ex when you had wonderful years and it ended because love died out
-2
u/L0G1C_lolilover Mar 01 '20
Anything is better than writing document.getelementbyid i know i could assign that to a variable but meh too much work
$() works best for me