TNS
VOXPOP
You’re most productive when…
A recent TNS post discussed the factors that make developers productive. You code best when:
The work is interesting to me.
0%
I get lots of uninterrupted work time.
0%
I am well-supported by a good toolset.
0%
I understand the entire code base.
0%
All of the above.
0%
I am equally productive all the time.
0%
Frontend Development / Open Source / Software Development

Why Outdated jQuery Is Still the Dominant JavaScript Library

jQuery is one of the longest running and most influential JavaScript libraries on the web. How has it stood the test of time?
Oct 25th, 2021 6:00am by
Featued image for: Why Outdated jQuery Is Still the Dominant JavaScript Library
Feature image via Pexels.

Richard MacManus
Richard is senior editor at The New Stack and writes a weekly column about web and application development trends. Previously he founded ReadWriteWeb in 2003 and built it into one of the world’s most influential technology news and analysis sites. Follow him on Twitter @ricmac.

jQuery is one of the longest-running and most influential JavaScript libraries on the web. A staggering 78% of the top 1 million websites use jQuery in some way, according to BuiltWith. As for the most talked-about JavaScript library today, React, it’s used by a relatively paltry 14%.

jQuery was launched way back in 2006, when the term “Ajax” was at its peak. Ajax (Asynchronous JavaScript and XML) is now long gone from the developer vernacular, along with other JavaScript technologies of that early Web 2.0 era. But jQuery has stood the test of time. Indeed, up till very recently, it was still growing year-over-year. To find out the latest on this enduring technology, I spoke to one of the developers who continues to maintain jQuery, Michał Gołębiowski-Owczarek.

Gołębiowski-Owczarek was the co-author of two articles on the OpenJS Foundation’s blog earlier this month, which addressed ongoing “modernization efforts” in the jQuery project. The first post announced a new version of jQuery UI — a user interface library built on top of the core jQuery library. It will be “the project’s final planned release,” meaning that jQuery UI is now “in maintenance-only mode.” The second post announced the deprecation of jQuery Mobile, another sub-project of jQuery that provided an “HTML5-based user interface system” for mobile browsers.

Both of these projects have been winding down since 2018, when they were made “Emeritus projects” of the OpenJS Foundation. Neither of the announcements, though, affects the so-called jQuery Core project, which continues to be an “Impact project” of the OpenJS Foundation. In other words, the main jQuery project isn’t going away any time soon.

The WordPress Factor

Despite its enormous usage, developers today may not even be aware that they’re using jQuery. That’s because it’s embedded in a number of large projects — most notably, the WordPress platform. Many WordPress themes and plugins rely on jQuery. The jQuery library is also a foundational layer of some of today’s most popular JavaScript frameworks and toolkits, like AngularJS and Bootstrap (version 4.0 and below).

“A lot of the surprise about jQuery usage stats comes from living in a bubble,” Gołębiowski-Owczarek told me. “Most websites are not complex Web apps needing a sophisticated framework, [they are] mostly static sites with some dynamic behaviors — often written using WordPress. jQuery is still very popular there; it works and it’s simple, so people don’t feel the need to stop using it.”

jQuery will continue to be a part of WordPress for some time to come, if for no other reason that it would be difficult to remove it without breaking backward compatibility. But I asked Gołębiowski-Owczarek if WordPress is likely to eventually move away from its reliance on jQuery?

“I think it’s partially already happening,” he replied. “The Gutenberg editor that WordPress created doesn’t depend on jQuery. So at least on the admin side, they have variations that are not dependent on it.”

He expects that over time WordPress will move onto newer technologies, but that it will be a gradual process.

Among the WordPress developer community, the “performance impact of using jQuery in WordPress themes” is a hot topic. There’s even a reference website called “You might not need jQuery” that offers tips on how to replace jQuery in your WordPress application. Its reasoning includes the fact that with modern browsers, “you might not need anything more than what the browser ships with.”

However, there’s another document that warns that “developers should be aware that ditching libraries, like jQuery, can easily require large amounts of research on their end to avoid bugs (even in modern browsers).” So despite the fact that “Is jQuery dead?” articles have been circulating for several years, it’s very much still alive in the WordPress ecosystem at least. Developers are being encouraged to replace it, but at their own risk.

jQuery’s Role Then…

So how did jQuery come to be so embedded in today’s web? A little history is needed to answer that.

When jQuery creator John Resig released it in January 2006, at BarCampNYC, he wrote that “this code revolutionizes the way you can get Javascript to interact with HTML.” He was primarily referring to the fact that jQuery made it easier for developers to work with the DOM (Document Object Model). Remember, this was before Google Chrome had come along to shake things up, so it was an era of little browser innovation. Microsoft’s Internet Explorer had 85-90% of the browser market, with IE6 the dominant version. Even at the time, IE6 had a reputation as a historically bad browser.

Simon Willison, who Resig listed as one of his influences when creating jQuery, noted some of the problems JavaScript developers had with browsers in a June 2006 post:

“There are a number of problems in JavaScript (most of them originating with browser incompatibilities) that any moderately complex application will need to deal with — things like normalized event handling, DOM node selection, sane animation or drag and drop.”

This was the kind of thing Resig had set out to solve, although jQuery itself wasn’t mentioned in Willison’s post. The “big four” leading JavaScript libraries at that time were Dojo, MochiKit, Prototype/Scriptaculous, and the Yahoo UI Library. In a blog post about a year later, Willison admitted that he’d initially thought jQuery was “a cute hack,” but now recognized it as “an exceptionally clever piece of engineering.”

So basically, jQuery had been invented to help developers deal with the browser inadequacies of the time.

…jQuery’s Role Now

What is jQuery’s role in today’s web, when the leading browsers (even Safari!) are much more compliant with web standards? Also, the JavaScript standard itself has significantly improved over the past decade, especially after the release of ECMAScript 6 in 2015.

As noted, React has become the most talked-about JavaScript library of today. Modern frameworks, notably Next.js, have been founded on React. Other popular frameworks, such as Angular (the successor to AngularJS) have their own ecosystem of libraries. Today’s JavaScript frameworks also allow you to break the UI into components, making it easier to scale up an application.

“Those frameworks provide abstractions for easier synchronization between the data and the view,” said Gołębiowski-Owczarek about the likes of Next.js and Angular. “So their users no longer need to modify/access the DOM directly so often, and are often discouraged from doing that. In such an environment, using jQuery doesn’t make much sense. But that’s just a small part of the whole web ecosystem.”

However, Gołębiowski-Owczarek acknowledged that jQuery may have performance issues for large-scale applications.

“We’ve improved jQuery performance a lot over the years,” he said, “but there are some obstacles that are hard to deal with. One of them is that to not conflict with the browser, jQuery doesn’t modify native prototypes — as some of the other libraries did (often later causing issues with standardization of conflicting APIs) — but it instead wraps DOM nodes with jQuery wrapper objects. Each operation on such a wrapper creates a new one. In most cases, it doesn’t matter, but for very complex applications with lots of DOM manipulation this can sometimes become an issue.”

Conclusion

It’s clear that jQuery is no longer an optimal way for developers to add JavaScript functionality to their website or application, especially if it needs to scale. The fact that GitHub contributions to jQuery are well down on its peak years (2006 till around 2013) also signifies that not much more can be done to make jQuery more compatible with our current web.

But that’s ok. jQuery has lasted a lot longer than most developers would’ve expected, given it came out near the beginning of Web 2.0. It still does the job it set out to do, after all, and it remains a convenient JavaScript library for developers to reach for.

In any case, jQuery will be embedded in tens of millions of WordPress sites for years to come. It may even outlast React.

Group Created with Sketch.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.