Why I hate jQuery (among other library/frameworks)

smalpierre

New member
If you get into things like dynamic menus, AJAX, and practically anything else JavaScript related, you've heard of jQuery. Oh it's so great, it does everything for you! Oh, it makes AJAX easy! It's the best thing EVAR!!! You don't even have to download it, just load it from CDN!!

Yeah yeah - I've heard all this nonsensical garbage before. Here's why I think it's terrible.

1. You learn the "jQuery way" which honestly the function chaining while cool in a way - in practice is clunky. You're piping one function into another into another into another ad nauseum. This makes the code less readable.

2. If you do chose to download it, and want to actually see the source, it's not a small tiny lightweight piece of code. Even minified / gzipped it's not tiny.

3. It's one more dependency that's unnecessary. AJAX in vanilla js isn't that difficult, and it certainly doesn't require 30k of code to download to the browser. My AJAX library is something like 80 lines of commented code, nowhere NEAR 30k.

4. It doesn't really make things easy, it makes most things even more difficult in many cases - and it's not as flexible as just directly using the language. It just gets in the way. It doesn't do everything for you, and often times it takes MORE jQuery code than if you just did it in JS directly.

5. People and their jQuery examples online ... it's hard to find useful examples in plain old JavaScript anymore. The search engines are LOADED with jQuery examples, examples specific to doing things in sitepoint, or portlets, and even THOSE are usually jQuery instead of JavaScript.

6. CDN sucks. What happens if their site goes down? What happens if they decide to change something? Not saying that they WILL, but you don't have control over your codebase at that point, and that is a BIG no-no in my book. I guess it's fine for prototyping, but you should download the code, and serve it from your server for production sites.

In short - no matter how shiny it looks on the outside, and how much it can do - you're probably not going to use 99% of it's functionality anyway. You're better off writing your own simple libraries to do what you want, how you want.

There is a time and a place for libraries, but abstracting away the entire base language is crazy, and that's what it tries to do. If you're going to use jQuery UI elements and ONLY jQuery UI elements, by all means use it! But beware - there is going to be SOMETHING you don't like, or it doesn't do. In most cases you're better off building one element at a time, using best practices in the base language. It'll be faster, lighter, more flexible, and FAR easier to read the code.
 

GigaGreg

Moderator
Staff member
I use jQuery all the time when developing Bootstrap websites or any other kind of websites. jQuery seems to be one of the coolest things ever created.
 

jaran

New member
Just remember to you if blogspot basically using javascript to operate all execute command. Many newbie using it but they are not realize it. Big company likes facebook and google will spending alot budget if they are not using javacript. PHP is sometime efficient but needs more resources in the same time. Its different with javascript. If you are as developer side, you should thinking how to make your server still can be access by own user without server get doubt.
 
How can anybody say Jquery is cool or makes anything attractive? Its useless code. Its filled with holes and makes no sense whats so ever. It seems the younger generation thinks its cool to add code and more code to make other code work, then add more code to get that to work. The forgot the old proverb of KISS, Keep It Simple Stupid.

I have a facebook app. It used Java script for some time functions. Its worked for years, not to get them to work, you have to add more code, and then add Jquery functions with Ajax. It has gone from 5 lines of code to 10 lines of code, hook, another file to run it and a library. I have over 300 files, 10 folders and half the time it doesn't work. I have to keep on top of it. It also changes between FF and Chrome. Some days it works in both browsers fine and then other days it works in Chrome only. I am at the point that I want to find the idiot who thought it would be cool to use this and smash them with a hammer. If I had the time, I would rewrite the whole code system and go old school.
 

Genesis

Administrator
Staff member
strokerace said:
How can anybody say Jquery is cool or makes anything attractive? Its useless code. Its filled with holes and makes no sense whats so ever. It seems the younger generation thinks its cool to add code and more code to make other code work, then add more code to get that to work. The forgot the old proverb of KISS, Keep It Simple Stupid.
WordPress is symbolically the same. At least up to a couple or more years ago the CSS and code were legible and easy to modify, but now there are so many themes turned out, the authors aren't taking as much care with the CSS and code as they used to, because for every little sin or omission in the CSS and code there is always a handy plugin with some more sins, more security gaps, now we get security plugins as well. Like layer upon layer upon layer of stuff on top of a house with very little foundation. The plugins are propping up the house and sometimes even making it fly. And then people wonder why there is so much hacking going on with WordPress sites in particular. :p
 

smalpierre

New member
jaran said:
Just remember to you if blogspot basically using javascript to operate all execute command. Many newbie using it but they are not realize it. Big company likes facebook and google will spending alot budget if they are not using javacript. PHP is sometime efficient but needs more resources in the same time. Its different with javascript. If you are as developer side, you should thinking how to make your server still can be access by own user without server get doubt.

Oh I AM using JavaScript, but jQuery is not synonymous with JavaScript. It's not part of the language, it's a library/framework - whatever you want to call it. That's exactly why I hate it so much - everywhere you go to look for an example of how something is done in JavaScript, you find nothing but a bunch of jQuery with the occasional prototype or mootools example - but you really have to dig to get to some real actual JavaScript examples.

It would be as if you went looking for a tutorial on setting up a website, and all you could find is how to install Wordpress - and nothing on HTML/CSS ...

My biggest problem with it might be that originally people used it was because ooohhh cross browser!!! Yeah - there should BE NO cross browser issues - that's what STANDARDS are for. Making bloated libraries to deal with problems with browsers is giving the browser makers a pass on adhering to standards - and I've got to say the nay no! And another thing - the browsers are becoming more standards compliant all the time.

Take AJAX for example - now Microsoft does get a LITTLE bit of a pass on this one because they DID invent it, and it was an ActiveX control long before it became a standard .. but now it's a standard, and Microsoft does it the standard way since IE7 just like every other browser. So why on earth do we need a library to handle cross browser issues with AJAX? Even if you want to support IE6, how hard is it to do this?:

if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}

If the browser supports the standard, use it - otherwise, it's IE so use the ActiveX control.

Here's another dilema - you've got code written for jQuery 1.8, now you build something that requires 2.1 so you upgrade ... and break a bunch of code that depends on the older jQuery version in the process. So do you load 2 versions of jQuery and now have twice as much bloated code running the wire, or do you drop the new feature? Or do you revamp a bunch of code to work with the newer library? No matter how you look at it - you're screwed.


strokerace said:
How can anybody say Jquery is cool or makes anything attractive? Its useless code. Its filled with holes and makes no sense whats so ever. It seems the younger generation thinks its cool to add code and more code to make other code work, then add more code to get that to work. The forgot the old proverb of KISS, Keep It Simple Stupid.

I have a facebook app. It used Java script for some time functions. Its worked for years, not to get them to work, you have to add more code, and then add Jquery functions with Ajax. It has gone from 5 lines of code to 10 lines of code, hook, another file to run it and a library. I have over 300 files, 10 folders and half the time it doesn't work. I have to keep on top of it. It also changes between FF and Chrome. Some days it works in both browsers fine and then other days it works in Chrome only. I am at the point that I want to find the idiot who thought it would be cool to use this and smash them with a hammer. If I had the time, I would rewrite the whole code system and go old school.

Yes - THAT! jQuery is an unreadable mess when it gets beyond a few lines, and it doesn't save any code. You might only have to WRITE 1 line of code, but you've got to load a huge library for it to work - you're sending 100 times the data down the wire to do the same thing.

Not to mention the 5 lines of code that you're writing to replace that one line of jQuery code is properly formatted so you can read it? Yeah - you could condense it to a single line and be just like jQuery - an unreadable train wreck.

And another thing - I've seen 10 lines of jQuery replaced with 2 lines of vanilla JavaScript in some cases. It's faster, more readable, a standard programming language found in every browser ...

Yes - code piled on top of more code to make this other code work, then you've got to do a song and dance ... No thanks! It's like they think more lines of code makes it better. Then there's that you have no control over how exactly things work - it's all magic'd up in the library.

Stroke - You can use my hammer, I'll hold him down for you. Then we can find the inventor of jQuery and burn him at the stake :D

I've found that often it's less time consuming to scrap the crazy junk some other guy dreamed up and just do it the sane way. Especially if you're going to have to work on it again in the future.
 

smalpierre

New member
Here's a PEFECT example of what I'm talking about:

Note jQuery is supposed to "fix" cross browser issues ...

http://stackoverflow.com/questions/...ser-support-html5-file-upload-formdata-object

If you're trying to test for browser availability of a very specific item (in this case FormData for using xmlhttprequest to send post data) WHY would you use a library that is designed to abstract away browser specificity to test for something browser specific?

I'll cheat and give the answer - because "You ... are a bozo, and have no business writing code" that's why. Now if the question is "does this abstraction library have a workaround" then these bits of code are valid - but that's not the question here. The question is simple. The test is simple. The "answers" given involve 30k of code to do the job of 4 lines including formatting:

function supportAjaxUploadProgressEvents() {
var xhr = new XMLHttpRequest();
return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
};

The original jQuery in question is ... MUCH bigger, AND you have to send a 30k library down the pipe to do it.

At this point, I'll NEVER allow a designer to use jQuery, or it's ilk on my sites. I don't care how beneficial they think it is. Build the UI elements I ask for, with the dependencies I allow or hit the highway because I'm the guy that has to deal with that lazy sloppy code later. I'm the guy that has to answer for crumby performance.

@"strokerace"
 

Yozora

Moderator
@"smalpierre"
I'm curious, would you recommend learning jQuery in any depth after someone's learned JavaScript? I'm learning JavaScript currently (or more like, I'm finally going through a big book on it instead of relying on the bits I've picked up from looking through code.), and all of the things based on it are kind of overwhelming. jQuery, Node.js, etc. Makes me wonder how many of them would really be useful to learn after JavaScript...
 

smalpierre

New member
@"Yozora"

That depends on what you want to do.

Node.js is for the server side if I'm not mistaken, I use PHP for that for a reason. It's stable, relatively fast, easy to code, plenty of features, and it's everywhere. I don't see any advantages for Node.js.

The client side libraries, maybe use them if it makes something very time consuming or difficult - very easy. Then weigh it against the penalty of having to load that library, and manage the dependency. Most things are better done without them though, and a lot of times they can get in the way.

Sometimes that's what an employer uses, so that's what you use. I wouldn't have picked .NET, Java, or classic ASP for any of the sites I worked on, but that was the specification of the jobs so I did it.

How in depth you learn it should depend on how much you use it - it'll come naturally. I don't know any of those libraries in any great depth, because the usually have been more in the way than a help. So I know basically how they work, and that it's usually better in every way to not use them.

There was a time this wasn't really true, back in the ie6 days when the browsers were nowhere near as standards compliant as they are now, it was a great advantage in some ways, but if there was a bug ... very difficult to get fixed.
 

smalpierre

New member
Exactly Stroke! My only disagreement is that if you're doing a lot of javascript, you're still better off doing it yourself most of the time since you have much more control over how it works.
 
I thought that a lot of this stuff was just me being old and stubborn and not wanting to advance with the changes. Not going to say I am any good at coding with PHP or anything else. I have always thought things should be short, simple and clean. It seems each year, more code is added to do the samething it did 5 years ago. Now with php 5.4 and mysqli, they have omitted stuff but added more code to accomplish the samething that you did in 5.3. When I started out with PHP 14 years ago, we used XML for our RSS feed scripts. Now, all of that stuff is being included in php script. Now, instead of using an include(or require) a file, they put that code in each and every file. It has become messy, confusing and then it opens security holes in a file. And so on and on. At first, the hole where caused by the coder themselves, now, it has to do with what you want a file to do that causes the issues when you add so much code to a file. You use javacript, Ajax, jquery php, html and CSS code in one file now.

When I took over my CMS, it took me a bit to figure out what the code was and then I cleaned it up. My latest project I have now, I have been working on it for 2 years and no further ahead with it then I was when I took it over. I started to remove all the style and put it into a CSS file, but even that didn't always work. The jquery and js in the same file seems to conflict with each other. Maybe they are correct, you can't teach an old dog new tricks.
 

Yozora

Moderator
@"smalpierre"
Thanks! Hmm, after I finish the JavaScript book maybe I'll learn jQuery so I can throw it on my resume, but not spend as much time on it as I'm doing with JavaScript, and then see if CoffeeScript is worth learning. I did an independent study on PHP in my last year of college (me + a big, thick programming book + coding projects + a professor to ask for help when needed = my favorite course ever XD ), but I graduated a couple years ago, began working, & mostly work on WordPress sites now. I'm just starting to get the hang of using PHP in WordPress. I really should learn more about PHP sometime. I had lots of fun using it.

Maybe my problem is that I try to learn too many things at once because I like coding too much...I should work on getting up to speed on languages I already know (CSS flexbox, other CSS3 & HTML5 stuff) before learning more, and then save the back-end stuff for when I've finished everything else, since my job deals mostly with front-end dev & design, and back-end dev is more of a hobby right now.

I'm glad I wasn't working on sites during the ie6 days...I've heard horror stories about trying to make things work in it. No wonder you seem to know so much!
 

smalpierre

New member
strokerace said:
I thought that a lot of this stuff was just me being old and stubborn and not wanting to advance with the changes. Not going to say I am any good at coding with PHP or anything else. I have always thought things should be short, simple and clean. It seems each year, more code is added to do the samething it did 5 years ago. Now with php 5.4 and mysqli, they have omitted stuff but added more code to accomplish the samething that you did in 5.3. When I started out with PHP 14 years ago, we used XML for our RSS feed scripts. Now, all of that stuff is being included in php script. Now, instead of using an include(or require) a file, they put that code in each and every file. It has become messy, confusing and then it opens security holes in a file. And so on and on. At first, the hole where caused by the coder themselves, now, it has to do with what you want a file to do that causes the issues when you add so much code to a file. You use javacript, Ajax, jquery php, html and CSS code in one file now.

When I took over my CMS, it took me a bit to figure out what the code was and then I cleaned it up. My latest project I have now, I have been working on it for 2 years and no further ahead with it then I was when I took it over. I started to remove all the style and put it into a CSS file, but even that didn't always work. The jquery and js in the same file seems to conflict with each other. Maybe they are correct, you can't teach an old dog new tricks.

Codebases have become a nightmarish chain of crazy bloated dependenies, and it's not necessary.

PHP and MySql have come a long way since back then though, if you use the advanced features. I do agree that having huge bloated dependency chains, and using plugins as a magic bullet is a security flaw. How many sites have I heard of hacked because of a Wordpress plugin?


Yozora said:
@"smalpierre"
Thanks! Hmm, after I finish the JavaScript book maybe I'll learn jQuery so I can throw it on my resume, but not spend as much time on it as I'm doing with JavaScript, and then see if CoffeeScript is worth learning. I did an independent study on PHP in my last year of college (me + a big, thick programming book + coding projects + a professor to ask for help when needed = my favorite course ever XD ), but I graduated a couple years ago, began working, & mostly work on WordPress sites now. I'm just starting to get the hang of using PHP in WordPress. I really should learn more about PHP sometime. I had lots of fun using it.

Maybe my problem is that I try to learn too many things at once because I like coding too much...I should work on getting up to speed on languages I already know (CSS flexbox, other CSS3 & HTML5 stuff) before learning more, and then save the back-end stuff for when I've finished everything else, since my job deals mostly with front-end dev & design, and back-end dev is more of a hobby right now.

I'm glad I wasn't working on sites during the ie6 days...I've heard horror stories about trying to make things work in it. No wonder you seem to know so much!


Get through one thing at a time :)

Wordpress will quickly become that thing that gets in your way if you get into custom back ends.
 

Olivr3000

New member
I agree with the original post! JQuery should have the same syntax as JavaScript, but instead, you have to completely learn the new way. Just looking at the JQuery code makes no indication that it is actually JS. Many of the things that are used in JQuery can be done easily with CSS / HTML / Vanilla JS.
 

LiveWire

New member
I work in a IT service firm and do Web App Development.

I extensively use jQuery on all the JSP webpages. I get easy control on all the html elements using jQuery.
Their UI framework is just awsome. No need to do more CSS.