GOV.UK dropped their jQuery dependency from their front end. You’ll never
guess what happened. (Yes, you will.)
jQuery is a roughly 30 KiB dependency that nearly 84% of mobile pages used in 2021—and for good reason. jQuery was an instrumental tool in a time when we really needed a way to script interactivity in a way that smoothed over the differing implementations of stuff like event handling, selecting elements, animating elements, and so on.
The web is better because of jQuery—not just because it has such incredible utility, but because its ubiquity led to making what it provided part of the web platform itself. Nowadays, we can do just about anything jQuery can do in vanilla JavaScript:
- We can select elements using a CSS selector syntax with
querySelector
andquerySelectorAll
. - We can add, remove, and toggle classes on elements with the
classList API
. - We can attach event handlers to DOM elements and the
window
usingaddEventListener
. - And so, so, much more.
It really begs the question: Do we really need jQuery today? That’s a question that GOV.UK has answered w