DEV Community

Discussion on: Who still regularly uses jQuery?

Collapse
 
sroehrl profile image
neoan

Uff. This would be a lengthy discussion as you can of course write nicely. The emphasis was in "invites [... writing terrible code]".

On a high level, DOM interactions are normally done by directly using the selector, usually wrapping the same elements over and over again.

$("#btn").click(function (){

    $("#btn").html("resend");
    // Or
    $(this).html("resend");

});

Both of these common options are strange as in the first version we create a new instance while the second one takes the this object which does not inherit the jQuery prototypes and therefore needs to be wrapped into a jQuery element again. This is especially weird considering that most listeners are shorthands for .on(event, function(event){}), which would hand you the native source element.

The usual result is either assigning many variables globally or repeating selectors until the doctors come.