The GOV.UK team recently published “How and why we removed jQuery from GOV.UK“. This was an insightful look at how an organization can assess its tooling and whether something is still the best tool for the job. This is not a nudge to strip libraries out of your current project right now! Many of us may still be supporting legacy projects and browser requirements that prevent this from being a viable option.
Some of the criticism appears to be that the library size argument is negligible on modern network speeds and caching.
GOV.UK posted an update to address this criticism with metrics – “The impact of removing jQuery on our web performance“.
This article also makes the case for improving maintenance. Instead of upgrading disparate outdated versions of code and having to address security updates in a piecemeal approach, removing the dependency reduces this footprint. This is the dream of having the luxury for addressing technical debt.
Previously, GitHub also documented how they incrementally decoupled jQuery from their front-end code. Improving maintenance and developer experience played a role into their decision.
What caught my eye in particular was the link to the documentation on how to remove jQuery. Understanding how to decouple and perform migration steps are maintenance tasks that will continue to come up for websites and it’s reassuring to have a guide from someone that had to do the same.
Further musing on this subject turned up the old chestnuts “You Might Not Need jQuery” (2014), “(Now More Than Ever) You Might Not Need jQuery” (2017), “Is jQuery still relevant? (1)” (2016), and “Is jQuery still relevant? (2)” (2017).
Yet the website runs on React.
I guess it’s not about the network speeds, but by how trendy the libraries are
What’s wrong with react?
I believe the implication is that React isn’t perfect either. But the comments are probably not as much of a knock on React, as they are on how often developers jump ship to the next trend while showing disdain for the previous tech.
I don’t think comparing jQuery with React here helps: React provides a declarative API for creating interfaces and jQuery does not, it provides a imperative API, those are apples and oranges.
While it was a blessing in the past, nowadays many things that it brought are now available in modern browsers so it makes sense replacing it. Why loading a big script that many people used mostly to get many good features for older browsers but that modern browsers natively support nowadays? Does the web provide a native declarative API? From what I know, no. Maybe they could replace React with some lightweight alternative, some are React-compatible, but, at the moment, no alternative have as much support and a community as large as React, so it makes little sense to do that.
The first question one needs to ask is why jQuery was used in the UK government’s website.
Was it used to make programming uniform?
Was it used for compatibility across different browsers and browsers’ versions?
Was it used to perform some operations with less own code (faster development)?
There may be one or multiple of the above reasons or could be something else.
I read the articles on UK government’s blog but it seems they have not mentioned reason(s) for using jQuery. For removal of jQuery, they seems to have considered only pages’ performances of loading the pages. It’s unclear whether they have considered other matters or not!