jQuery: Why?

I’ve been wanting to explore this topic for a while. I still semi-frequently see job postings where they want jQuery expertise. And it’s not even an afterthought. It’s one of their top-listed, main requirements. So here’s a little history lesson on jQuery and maybe the answer to why you still see it on job postings.

According to Wikipedia, the initial release of jQuery was in 2006. jQuery was extremely useful at the time of its rocketing growth in popularity. This was a time when the industry’s best attempt at an interactive, database driven website typically involved PHP code intermingled with HTML and styles, all literally in the same file. We did not have libraries like AngularJS (2010) to bind models to view automatically. The way you updated a view with new state data was that you explicitly bound events like a button click to function that explicitly grabbed the DOM and altered its contents.

That is what jQuery does.

jQuery is first and foremost a library for querying the DOM associated to a web page to retrieve elements. You could get a single element by ID. You could get a list of elements by class. You could even pipe these lists through filters and do some fairly sophisticated things. But ultimately there were two main reasons why people used jQuery for this: (1) browsers either didn’t offer an API to do this or they all had different ways of doing it, and (2) we had to explicitly grab the DOM and imperatively alter views. There wasn’t some engine that did it for us.

jQuery also began doing a LOT of other things. A lot of people began to rely on jQuery for AJAX. jQuery offered an easy syntax that worked on all major browsers. We used that term “AJAX” for doing HTTP requests in the background without requiring a page reload. (By the way, people pronounce this acronym “ay-jax”, as a word.) AJAX basically is what we called Web 2.0. It’s when web apps became more like desktop apps because you didn’t have to constantly load a fresh page to get new information. People don’t even say “AJAX” anymore because it’s air. Every webpage uses AJAX now for everything. We don’t comment when there is air to breathe. And we don’t comment anymore when there is AJAX.

I saw a joke once. It was a picture made to look like a StackOverflow QA page. Someone asked about the best way to add two numbers in JavaScript. Most people suggested that jQuery was the best way to add two numbers in JavaScript. One idiot suggested the JavaScript + (plus) operator, but he was shouted down. I think later the question was closed as off topic and some StackOverflow people with high reputation points commented on the OP’s mother’s hygiene and weight.

The niche of jQuery was to abstract away differences between the various browsers of the day. Internet Explorer in particular sucked really hard for its entire existence. They bucked standards. As with all Microsoft products, they just generally did shoddy work and it sucked. But SO many people used IE because it was built into Windows. So developers had to write code that was IE-compatible. We still do actually. IE 10 is still in use by enough of the population that companies still require devs to write code that works on IE 10. But it used to be a LOT worse. Like, nothing worked on every browser.

The most important difference between now and then is that major browsers started to adhere to JavaScript standards, and those standards evolved. They evolved some native APIs (also standardized) to implement functions that previously we had to use jQuery for. The method document.querySelectorAll is an example. Firefox, Safair, and Chrome became serious players. Chrome had Google money behind it, so Microsoft couldn’t afford to be so lazy with IE anymore. I mean, IE sucked so hard. But Firefox was excellent. Safari was excellent. And Chrome was the very model of a modern major browser. Also: Google advertised. A lot of people adopted Chrome. In the meantime, Microsoft chucked the name Internet Explorer in favor of Edge. They rebranded, which is to say they admitted defeat. Edge is not as terrible as most of Microsoft’s lazy attempts, but I don’t use it.

Another major change in browsers was auto-updated, evergreen browsers. Users don’t have to expressly go to a website and download the latest version anymore. Under normal circumstances, browsers update themselves. They get better, faster, and more reliable every day.

Here’s my professional opinion right now for what it’s worth: jQuery just isn’t necessary anymore. Explicit DOM manipulation is mostly a thing of the past. But you will still see jQuery (as of 2019) in legacy code. Companies out there are still hiring people to come in and rebuild old projects that were written in AngularJS and jQuery. You need to understand it when you read it. But it’s really just not that complicated. You don’t need to know it well enough to write it. It’s a dead language. Learn the basics well enough to read it. Then look up anything unfamiliar. And if you are still using it for animation, you should make sure you aren’t using it for something that is standard in CSS3 and broadly supported by all modern browsers.

jQuery was a great project. It changed the face of the internet. jQuery made itself irrelevant because it influenced everything to be more like jQuery. The stuff jQuery was doing got built into every browser. It shamed them all with its excellence. Bravo jQuery, really. But I sincerely hope I never need you again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s