DEV Community

Discussion on: Who still regularly uses jQuery?

Collapse
 
alangdm profile image
Alan Dávalos

If you really just love $() you can add this line to your JS

const $ = selector => document.querySelector(selector);
Enter fullscreen mode Exit fullscreen mode

or this one if you don't want to compile to es5

function $(selector) {
    return document.querySelector(selector);
}
Enter fullscreen mode Exit fullscreen mode

And remove JQuery as it's overkill to have your user download a whole library if that's all you want XD

Collapse
 
afewminutesofcode profile image
Aaron

Thats a great tip Alan! I agree that it is overkill and I haven't used it for a number of years. I think when I stopped using it I became a better developer and got a much better understanding of js.

Collapse
 
mateus_vahl profile image
Mateus Vahl
const $ = document.querySelectorAll.bind(document)