We use jQuery and I've stopped feeling ashamed about it

May 21, 2017

I'll start with my tweets:

A confession: I have a web site that uses jQuery. An old version of jQuery, at that. It probably always will, because it works this way.

I could spend a bunch of time (as a non-JS-expert) to make my site use current native browser APIs instead. But there's no payoff for us.

I've completely given up feeling guilty about still using jQuery and not updating our jQuery versions. Our site is a tool, not a sculpture.

One thing that I've been reading for some time is that jQuery is mostly unnecessary these days. Apparently jQuery was created back when browsers were more incompatible and less capable; these days, modern browsers have changed both aspects and for garden variety DOM manipulation you now have well supported cross-browser native APIs. Increasingly, it seems that the nebulous 'best practices' of modern JavaScript web development are to avoid jQuery unless you have a strong reason to use it.

(Typical writing about this is eg here, here, here, or this blog entry by Laurie Voss that mentions it in passing (via). Running across Laurie Voss's blog entry is what pushed me into my tweets.)

Beyond the sin of still using jQuery at all in our web app, we're also still using an old version of jQuery (specifically jQuery 1.9.0, released in early 2013 and so now more than four years old). This whole issue has been nagging at me for a while and today I reached the point where I blurted out my tweets, which perhaps isn't the conclusion you might expect.

The reasons I've wound up here are straightforwardly pragmatic. As I mentioned, there is essentially no payoff for us in updating our web app to avoid jQuery or even to use a more recent version of jQuery. Our app is a small low-usage thing and we only use JavaScript for some small enhancements that are very likely to be undemanding even in 'inefficient' jQuery code; similarly, the extra jQuery download is unlikely to be significant. Improving our JavaScript may make things more proper and perhaps if I was starting from scratch today I wouldn't use jQuery, but there is no concrete benefit to us for doing anything to the app as long as it continues to work. As I tweeted, our app is a tool that people use, not a sculpture for them to admire. People who use the app care somewhat about how it looks, but they don't care what's under the surface.

Some people would modernize our JavaScript anyway, just because the current state nags at them and they care. Perhaps I once was such a person in the past, but today I'm definitely not. I don't care that much and I have better things to do with my time (both work time and spare time). So I'm done with letting this nag at me and I'm not going to make any excuses for it.

(Perhaps I should drop in the latest 1.x jQuery and test lightly to see if everything works, just in case there's some bug fix that matters to us that we're missing. But even that is hard to sell, partly because it's still a hassle.)


Comments on this page:

As a developer who's fairly familiar with JavaScript, I think the anti-jQuery stuff has gone too far in some cases. I still use it myself, since some things are much easier to do with it, even if you know the non-jQuery way (like toggling a class or making an HTTP request).

The only thing that annoys me about jQuery is tutorials and Stack Overflow answers which teach everything in terms of jQuery so new JavaScript users think there's no way to do anything without it.

Written on 21 May 2017.
« A 'null MX' is also useful for blocking forged senders from non-email domains
Safely using Python's Global Interpreter Lock is quite tricky and subtle »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun May 21 22:24:16 2017
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.