Why Gov.UK, the UK’s public sector information site, has stopped using jQuery. Is the JavaScript library still as useful and essential as it was in its early days?


Do we really need jQuery today? It’s a question that GOV.UK and the Bootsrap team have answered in the negative. The head of the UK government’s Digital Transformation Unit recently announced a change in the country’s government services site gov.uk*: they’ve removed jQuery as a dependency for all front-end applications, which means 32*KB of minified and compressed JavaScript code has been removed everything from selecting items to Attach event listeners. As a developer, what do you think?

jQuery was created to simplify writing JavaScript and HTML, and arrived back in time in 2006, with the increasing complexity of web interfaces. This has enabled it to attract web developers en masse and gain essential component status in web technology training.

jQuery is a ~30*KB dependency used by roughly 84*% of mobile pages in 2021, and for good reason. jQuery was useful at a time when we really needed a way to program interactively in a way that simplified various implementations of things like event handling, element selection, element animation, etc.

Here is an example of Ajax with jQuery:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

$(document).ready(function() {                    // Lorsque le document est chargé
    $(".load_page_on_click").click(function() {   // Lorsque l’on clique sur un élément d'attribut class "load_page_on_click"
        var email = $("input[name=email]").val(); // Variable contenant la valeur d'un élément input d'attribut name "email"
        $.ajax({                         // Exécution d’une requête Ajax avec la configuration donnée par l'objet suivant :
            async: "true",               // - requête asynchrone
            type: "GET",                 // - type HTTP GET
            url: "mapage.php",           // - URL de la page à charger
            data: "email=" + encodeURIComponent(email) + "&action=get_email", // - données à envoyer
            error: function(errorData) { // - fonction de rappel en cas d’erreur
                $("#error").html(errorData);
            },
            success: function(data) {    // - fonction de rappel pour le traitement des données reçues en cas de succès
                $("#container").html(data); $("#error").append("Contenu chargé");
            }
        }); // Fermeture de l'appel à la fonction $.ajax
    });     // Fermeture de la fonction de rappel du $(".load_page_on_click").click
});         // Fermeture de la fonction de rappel du $(document).ready

The web is better with jQuery, not only because it's incredibly useful, but because its ubiquity has resulted in its incorporation into the web platform itself. Nowadays we can do just about anything jQuery can do in vanilla JavaScript (a name to refer to when developers use plain JavaScript without any additional libraries like jQuery):

  • We can define elements using CSS selector syntax with Query And the Query.
  • We can add, remove and switch categories on items using API Layer List.
  • We can attach event handlers to DOM and window elements using addEventListener.
  • And so, much more.

jQuery has long not been the most widely used JS library in the world, and many frameworks have used it to work. But with the advent of new technologies (libraries and frameworks) and the updating of browsers, the inevitable character, and even the importance, of jQuery is no longer unanimous. Issues that used to require jQuery are now resolved by browsers and the evolving EcmaScript standard. So some developers are starting to distance themselves from the JavaScript library.

This is for example the case of the Bootstrap team who announced that they had abandoned jQuery from the first alpha version of Bootstrap 5 to return pure JavaScript. According to Mark Otto, the framework builder and author of the blog post announcing the release of alpha 1, jQuery has given unprecedented access to complex JavaScript behaviors to millions (billions?) of people over the past 15 years, and they probably never could have changed JavaScript itself. , but it's time to drop the jQuery team as a dependency element. According to the post, this change is made possible by developments in front-end developer tools and browser support.

The main argument for removing jQuery from Bootstrap v5 is that now over 95% of jQuery functions are native in browsers (the remaining 5% are arguably overly backwards compatible quirks worth being ignored), adding a dependency would be either stupid or a waste of display bandwidth.

In the developer community, opinions about this change differ. Those who have welcomed it understand that jQuery is one of the most important libraries in the history of JavaScript and has helped build real web applications. However, they believe that since then the differences between browsers have narrowed considerably, and we've learned how to create maintainable and scalable apps in a more straightforward way, thanks to frameworks like React, Angular, and others. Suddenly jQuery is no longer of much use.

Removing the jQuery selector engine due to the presence of native selectors in modern browsers tends to validate those who think jQuery has become irrelevant. Still others feel that the JS library is not outdated, because jQuery techniques are not easy to implement without jQuery. For the latter, it remains a very productive tool that offers simple solutions to many problems.

UK government website status

In March 2022 Matt Hobbs, Head of Front End Development for Government Digital Services (which offers platforms, products and services that help government become integrated, reliable and responsive to user needs including GOV.UK), announced that GOV.UK had removed the jQuery dependency. This is a huge problem when it comes to the user experience, as GOV.UK provides online services and information for the UK on a large scale. Not everyone uses their MacBook Pro 2022 for amazing broadband connectivity. GOV.UK should be accessible to everyone, and that means it should remain lightweight.

Here are some of Matt Hobbs' top hits on what GOV.UK noticed when removing jQuery*:

  • The front end processing time is generally less.
  • 11% lower block time at the 75th percentile.
  • 10% less blocking time for users in the 95th percentile. These are the users who experience very adverse network and device conditions, and every performance gain matters to them.

Matt's Twitter feed is filled with various information, including detailed performance measurement with and without jQuery.

source : Matt Hobbs

And you?

Have you developed in JavaScript recently? Have you used a framework like jQuery or another? Which ?
What do you think? Is jQuery still popular enough in 2022 in your opinion?
Do you think jQuery is still relevant due to the evolution of JavaScript and other parameters such as browsers, connection speeds, etc.? ? If the answer is yes, then why? If not, to what extent?
Is the JavaScript library still as useful and essential as it was in its early days?

See also:

Bootstrap 5 first alpha is available with updated forms and custom CSS properties, but without Internet Explorer and jQuery support
Bootstrap version 5.0 will remove Internet Explorer 11 support, and this follows the announcement that jQuery has been removed from JavaScript only

Leave a Comment