3 ms·
Can somebody explain to me what is so bad about jquery? I use jquery every single day to make web pages do the things that I want them to do. But my javascrip
by blhack 11y ago
Can somebody explain to me what is so bad about jquery? I use jquery every single day to make web pages do the things that I want them to do.
But my javascript hipster friends all claim that this is wrong and stupid and that I shouldn't use jquery because of some abstract reason that nobody ever seems to be able to articulate to me.
- joshcanhelp 11y agoMy $0.02 ... There's nothing wrong with just using jQuery. For many, many applications/projects it's a great tool and does everything you need. What happens as a project/app/site grows is that you add more and more and more jQuery to a single file and it starts to get hard to maintain (hard to find what you want, hard to change something without something else blowing up, hard to navigate the files you're using). Frameworks like React, Backbone, Angular, etc were made to drive large, complicated, often single-page applications where you have massive amounts of interacting code and want to generally simplify what you're writing and how it's architected. So, in the end, these are meant to help you organize code, be more productive, and have a more coherent architecture. That's the idea, at least. The tweetbot example here is simple because you're just learning so, if this is the only thing you're building on a page, it probably makes more sense to just use jQuery. I think the typical road from jQuery-only to using a framework is your apps get bigger and you start to think "this is hard to maintain." Then you see an example of a framework doing something that would really help your process and see how it could improve the code you're writing. You try it out, it makes the process easier/more enjoyable, and you continue learning more. Or it doesn't and you swear it off. AFAICT, these frameworks grow out of a person or team that figures out a more productive way to write code for what they're working on. That becomes a boilerplate they use, then grows into something they think would help others out. Then it gets a name and we all argue about it. In the end, it's just one person's/team's/company's idea of how to write code better, which may or may not work for other people/teams/companies.
- wging 11y agoThere are two arguments that could be made. 1: you can do without jquery, and therefore you should. if all you need is $('#my_id') then it's overkill and it's better to save on download speed by leaving jquery out. See http://youmightnotneedjquery.com/ http://youmightnotneedjquery.com/ That said, jquery is a powerful tool and it's widely used for a reason. 2: unrestrained use of jquery, if it's your only tool, can lead to code that is hard to understand, and easy to get wrong. if any part of your code can modify any part of your page, then it is a good idea to retreat from that and be careful/organized about what you do, and when/where you do it. that organization is what JS frameworks try to help with. you may or may not find your life is improved by such frameworks, depending on what you're doing.
- Raphmedia 11y agoNothing at all. Use jQuery. If things get unwieldy, split your code into multiple files, then merge & minify them with grunt or gulp.
- jayhuang 11y agoThere's nothing wrong with jQuery. Aside from extending and abstracting parts of JS and DOM traversal, it also removes many of the complexities with cross-browser support, especially with dated browsers. The biggest issue is when you take something like jQuery and try to have a multi member team working on a significantly complex and large application. It quickly gets out of hand, messy, and increasingly difficult to maintain. This is without taking into consideration the issues that arise if the developers on the team don't have a basic grasp of how to write jQuery code that still performs well with large amounts of actions/DOM manipulation. Many interviews for front-end positions also want to make sure you don't only know jQuery, but at least have some grasp on DOM traversal/manipulation without crutches like jQuery. A lot of the bashing though, is really just from people with a superiority complex instead of logical reasoning. Or it's just people who repeat what they hear, kind of like one of the largest hate trains of all: PHP. Kind of like the story about the monkeys, bananas, and a ladder: http://www.wisdompills.com/2014/05/28/the-famous-social-experiment-5-monkeys-a-ladder/ http://www.wisdompills.com/2014/05/28/the-famous-social-expe...