You Might Still Need jQuery, and this is why. Web developers are a fickle crowd. Yesterday’s best practices become today’s code smells, and today’s code smells may at one point end up being best practices. Friends, we are out of control. What is it that makes us so crazy and all over the place? Why do development workflows come in and out of fashion at such a rapid pace? Why does this problem seem to be getting worse and not better?! Right now, native JavaScript is all the rage. “Death to jQuery!” the hipsters shout. It’s really not quite that simple, let’s take a look at why this is so.
Web Developers Are Obsessive Compulsive
Once we find a new toy to play with, and get halfway decent with it, we must suddenly rewrite the entire world in said new toy. This groupthink feeds on itself, and pretty soon not only are you the only one that needs to rewrite everything with the new toy, now everyone needs to rewrite the world in the new toy!
This Is About Psychology, not Technology
This has so much more to do with people, and not the tools we use. People are crazy. Get a lot of them together, and you have more craziness. People are the reason we have Economic Bubbles, Alchemists, Crusades, Witch Hunts, and other delusions.
What is Cool?
Here is a challenge to you. Stop following what is cool. Stop trying to figure out the next big thing. Stop trying to be ahead of the curve. You are making youself miserable, and killing yourself in the process. How about looking at the particular challenge in front of you, and figuring out a way to solve your problem. As you think about solving your challenge, if you are worried about how others will perceive you based on your approach, you’re an idiot. Don’t be an idiot.
What Does This Have To Do with jQuery?
Everything. Much to the hipster’s chagrin, jQuery is the most popular, most mature, and most stable JavaScript library of all time. Think about that for a second. If you think jQuery is going away, you are crazy. You are believing the hype of hipster hacker, and the too cool for school crowd at hacker news. A mature, battle tested, and perfectly working solution is no longer cool. Again, this is not even so much about jQuery, as it is about all technologies that work extremely well and have done so for some time. People get bored, and when people get bored, they start to reinvent the wheel and solve the same damn problems in a completely different way. Enough ranting however, let’s see why You Might Still Need jQuery.
The Internet Is Not You
You are a web developer. You install new browser engines faster than Usain Bolt runs 100 metres. You ooooohhh and ahhhh over bleeding edge technologies, happily integrating alpha builds into your next project. The Internet however is not you. Hell, millions of people have no idea that Facebook is not the Internet! Consider the difference in user base between someone like yourself who could build a small scale version of a social network, to that of people who don’t know the difference between Facebook and the Internet. Do you think the latter are going to have the latest and greatest technologies and browser engines for which to surf the web?
Legacy Internet Explorer Lives
Internet Explorer 7 and even 6 still exists in the world. Yes, horrific, but true. Why make your life difficult? jQuery is a given in a situation like this, it just works. In addition, once you learn the API of jQuery, it is so dead simple and useful, why wouldn’t you use it?
True Artisans Code By Hand
No actually, true idiots reinvent the wheel and solve the same problem their own way with locally sourced ink and a feather quill, all in the name of doing it themselves, and being cool. Look at me! Native JavaScript! Hand Crafted! Nothing against native JavaScript, it is fantastic. When it is easier or syntactically more terse in jQuery however, you can bet your ass I’ll be doing it that way! jQuery still provides extremely useful tools which reduce the worry about fallbacks, browser support, workarounds, or inconsistent APIs. jQuery is just plain easier. Easier to write, maintain, refactor, debug, test, grep, Google, teach, understand, and extend!
Do note:
- jQuery is about 28kb minified (whiner: it’s too bloated!)
Only worry about jQuery after you have:
- minified all assets
- concatenated all assets
- gzipped all assets
- configured proper cache headers
- eliminated unneeded HTTP requests
A Re Introduction To jQuery
Ultimately, this leads us to a re introduction to jQuery. As a person who like to go against the grain, I take great joy in blogging about the virtues of jQuery. When a backlash reaches the heights it has currently for something like jQuery – then it is definitely a sign to dig your heels in. PHP backlash is also popular. Guess what? PHP fucking rocks. Laravel takes a lot of flack lately. Guess what? Laravel is the best PHP framework ever invented. Haters can suck it.
jQuery is a great way for newer web developers or designers to ease their way into native JavaScript coding. When John Resig came up with the syntax for jQuery, it was and remains a simply genius idea. Grab something in the page by a CSS selector, then do anything you want with it. The simple fact that this is so easy to do, and so useful, certainly merits included jQuery in any application. Many of us, myself included, actually made things like DOM manipulation, animations, event handling, and AJAX happen in jQuery before we were ever able to natively. This lowers the bar for people new to the field, and really is quite fun. Nowhere else can you get as much bang for your buck as a beginning programmer, than to be able to make some incredible animations and effects in the browser with just a couple lines of code. This gets newbies excited, and hungry to further their skills.
jQuery Makes Collaboration Easier
With jQuery being as popular and as entrenched as it is, if you need multiple developers to work on your project – they are going to understand jQuery. Web developers will more easily have a shared understanding of jQuery code patterns and API than roll your own solutions.
You Might Still Need jQuery Summary
Sure, You Might Not Need jQuery. You also might not need food, but I highly recommend for you to continue eating a normal healthy diet with fresh fruits and vegetables. Soylent Green (WTF is a soylent green), just might be the stupidest thing I’ve ever heard of. Make your life easier, use the tools that help you solve problems quickly and easily when applicable.