Don’t use jQuery? Why not?
Everyone once and a while, you see a blog post or website complaining about people using jQuery. There’s a lot of reason for people to say this, but from what I’ve seen, it really boils down to just a few reasons:
- Page bloat – jQuery adds anywhere from ~30 Kb to to ~180 Kb, depending on whether you use a production or test version
- jQuery encourages bad code – Since it’s so easy to learn, only amateurs use it and they write bad code
- Licensing issues – Some people are afraid of using third-party libraries, but jQuery is licensed under the MIT License, which is completely open source
- Well… that’s about it
Think about it this way. People use Java for several reasons. First, it’s easy to learn, much easier than lower-level languages such as C++, C, or even Assembly. It also has reusable packages, such as string and network utilities, so that you don’t have to rewrite that over and over again. Finally, writing an application once will let it run on any operating system (for all intents and purposes), as long as it has a JRE installed on it. Seeing some similarities?
Finally, just to address the bad code quality code, jQuery is a lot like PHP. PHP isn’t necessarily a bad language. Well, it is, but that’s besides point. PHP gets an even worse rap because, like jQuery, it has a low learning curve and is a popular choice to begin programming. Unfortunately, many of the amateurs write tutorials which many beginners use as a starting point, so a lot of PHP programmers never learn how to write good code in the first place and the problem repeats itself. However, good programmers can write very good PHP. Facebook, which everyone knows as one of the most visited sites today, used to, and still does to an extent, use PHP. In the same manner, if you follow some jQuery best practices, the code that you produce as a result will be quite fantastic.