"There's no real gain from jQuery, although syntax is typically slightly shorter." and with that comment the author completely misses the point of all wrappers/libraries all while stating something that is just completely untrue: "There's no real gain from jQuery". It's like saying "There's no real gain from jQuery, it just saves you a ton of time and energy but besides that it sucks".
This is a terrible idea. I've said it before and I'll say it again unless you only have to worry about support the newest Chrome/FF and even then the jQuery syntax is MUCH nicer than plain JS.
It's simply not worth a developers time to account for all the different ways to accomplish the same end-task in all browsers. I know that when I use jQuery I can count on it working the same in every browser without having to test it extensively. The same cannot be said for plain JS. I know this is getting better but if you need to support a few versions back of IE (8/9) then not using jQuery is like shooting yourself in the foot. I am fully in support of using less jQuery and being smart about caching selectors and the like but not using jQuery is very bad advice unless you are suggesting a full framework in it's place which does all the things jQuery does.
Let's take a quick minute and look at the company behind this site: http://pixabay.com/ They are a picture hosting (possibly selling? IDK) site. I'm sure FOR THEM they can get away with just plain JS but for people actually building web apps or building multiple client sites it's not nearly as easy. So not only do I think their site would be fairly simple to create without jQuery if we take a little look at the source we see THEY ARE USING jQUERY! Just think about that, the company behind a website urging you not to use jQuery is using jQuery on their own site...
Lastly using libraries that don't use jQuery will (9 times out of 10) set you up for failure unless the developer behind the library did extensive tests in every browser. I personally am more a fan of things working everywhere then trying to shave off the time that jQuery might add. If you want to convince me on how bad jQuery is you are going to need to show some benchmarks to prove your point. I, for one, do not accept that across the board jQuery is slow and using native JS will make my app "load and react blazingly fast". With or without jQuery you can write shitty code, it's not jQuery's fault it's the developers...
Answering in the name of Pixabay: We started Pixabay years ago and at the time, jQuery was kind of the holy grail in terms of cross browser safe JS development. However, times change and today we would use vanilla JS for the site. And the day will come when we finally take the time to rewrite the code.
Yet, I totally admit, there are use cases where jQuery is still extremely useful. E.g. online web page editors, such as Wix.com or HubPages.com ...
I actually love jQuery! Yet, plain JS has become pretty cross browser safe and once familiar with it, it isn't harder to develop most sites in vanilla JS.
Also, useful methods previously known only to jQuery get accepted as DOM methods. E.g. DOM4 includes methods like .closest(), .append(), or .prepend(), etc. This makes plain DOM manipulation similarly readable as jQuery. But it's not yet widely supported ...
> This makes plain JS code similarly readable as jQuery.
Please correct your sentence, "This makes plain DOM manipulation similarly readable as jQuery". Or are you suggesting that when one uses jQuery, which is a javascript library dealing with DOM manipulation, one isn't writing plain javascript code ? but using some third party language ? which is a false statement.
I'm going to need to see a complete site NOT using jQuery made by the people behind this before I can accept "However, times change and today we would use vanilla JS for the site.". You probably believe that statement 100% but it's an easy statement to make without the work to back it up.
> I actually love jQuery! Yet, plain JS has become pretty cross browser safe and once familiar with it, it isn't harder to develop most sites in vanilla JS.
I fundamentally disagree with this statement and I think it comes from someone who either hasn't done it or has done it on a tiny scale which doesn't really stress your JS chops.
> Also, useful methods previously known only to jQuery get accepted as DOM methods. E.g. DOM4 includes methods like .closest(), .append(), or .prepend(), etc. This makes plain DOM manipulation similarly readable as jQuery. But it's not yet widely supported ...
All the more reason to keep using jQuery in my opinion. jQuery will use the built-in methods if they exist and "polyfill" (yes I know that's not exactly the right usage of that word) the parts the browser doesn't all without bothering the developer.
The thing I keep coming back to is when people go down this PlainJS route here is what undoubtedly happens:
1) Oh yeah! Look how cool I am, I don't need no stinking jQuery!
2) Hmm, this doesn't work the same in both browsers. I'll just created this little helper functions to handle the differences.
3) Repeat #3 1 to Infinite number of times
*) Oh... Well my helper library has grown quite big and does pretty much what jQuery does (not all of it but most) all without being thoroughly tested nor being used by a MASSIVE chunk of the internet.
You almost always end up re-creating jQuery or parts of with the same slowdowns you worked so hard to avoid. All while making your codebase MUCH less readable and making it harder to bring new developers on the team up to speed with not only your PlainJS way but also your completely custom jQuery-clone. People can keep selling them "jQuery is so big and slow" story and I'll keep not buying it... I will GLADLY sacrifice a little speed here and there for the hundreds of hours of QA/Debugging/Bug-fixing I will save and I think most developers would agree. There is a reason that browsers implemented things jQuery does... BECAUSE IT MAKES SENSE, I'd rather be on the cutting edge of what CAN be done instead of waiting for browsers to implement it and users to upgrade. It's close to the same reason we use Babel JS to transpile our ES6 to ES5, I'm not going to wait for those new features when I can be using them today which results in not only speed ups in development time but also future-proofing our code to a degree. With jQuery if there is a faster or better way to do something all I need to do is upgrade jQuery to take advantage of it which cannot be said for your approach which would result in either not using the new stuff or writing your own wrapper to handle the differences between browsers (new functionality may ship fast in evergreen browsers but the first few implementations rarely match cross-browser implementations which is why we have jQuery.
jQuery is perfect for rather complex JS driven websites, e.g. web page builders. But most websites that make use of jQuery just don't need it.
As an example website we created without jQuery: plainJS.com :-P The site provides a neat interface with features like autocomplete search and syntax highlighting. And the whole page works nicely down to IE 8.
I was surprised how simple it is - and in the process we've also released some Vanilla JS plugins. Also, I was surprised how many modern Vanilla JS plugins there already are!
So where would be the point to use jQuery on plainJS.com? It neither makes development or maintenance easier, nor is it faster - but it add a third party dependency.
You have like 1.000.000 js libs from external sources, mostly from Social Networks and you think about maintance and third party dependencies?
Oh my god..
Dude, there are so many Tools around JavaScript at that time, that you should prolly stop integrating 1 million Social Sites and instead focus on JavaScript and testing.
Especially when you want your site to be faster.
While I agree with you that the author completely missed the point I have to disagree with this assertion:
" I've said it before and I'll say it again unless you only have to worry about support the newest Chrome/FF[...]It's simply not worth a developers time to account for all the different ways to accomplish the same end-task in all browsers.[...]Lastly using libraries that don't use jQuery will (9 times out of 10) set you up for failure unless the developer behind the library did extensive tests in every browser. "
What you purport was true 4 years ago. Yes IE 9 and 10 are kinda crappy but essentially every browser in the past 4 years supports at least the same way of manipulating the DOM. Yeah there are weird quirks when you use non standard stuff like innerHTML with IE but if you're sticking to the HTML / DOM spec then unless you're targeting an older browser there is a good chance you're fine. You should be using feature detection for graceful degradation regardless if you're using jQuery or not.
Yeah jQuery providers a better API and yeah if you want to support older browsers then it's a good idea. But saying not using jQuery is only targeting the "newest" browsers is just disingenuous.
but but but "you might not need jquery", all you need is a million extensively tested hand coded if typeof !== undefined and try catches to support enterprise clients. Why would you not want to do that?
This is a terrible idea. I've said it before and I'll say it again unless you only have to worry about support the newest Chrome/FF and even then the jQuery syntax is MUCH nicer than plain JS.
It's simply not worth a developers time to account for all the different ways to accomplish the same end-task in all browsers. I know that when I use jQuery I can count on it working the same in every browser without having to test it extensively. The same cannot be said for plain JS. I know this is getting better but if you need to support a few versions back of IE (8/9) then not using jQuery is like shooting yourself in the foot. I am fully in support of using less jQuery and being smart about caching selectors and the like but not using jQuery is very bad advice unless you are suggesting a full framework in it's place which does all the things jQuery does.
Let's take a quick minute and look at the company behind this site: http://pixabay.com/ They are a picture hosting (possibly selling? IDK) site. I'm sure FOR THEM they can get away with just plain JS but for people actually building web apps or building multiple client sites it's not nearly as easy. So not only do I think their site would be fairly simple to create without jQuery if we take a little look at the source we see THEY ARE USING jQUERY! Just think about that, the company behind a website urging you not to use jQuery is using jQuery on their own site...
Lastly using libraries that don't use jQuery will (9 times out of 10) set you up for failure unless the developer behind the library did extensive tests in every browser. I personally am more a fan of things working everywhere then trying to shave off the time that jQuery might add. If you want to convince me on how bad jQuery is you are going to need to show some benchmarks to prove your point. I, for one, do not accept that across the board jQuery is slow and using native JS will make my app "load and react blazingly fast". With or without jQuery you can write shitty code, it's not jQuery's fault it's the developers...