r/ProgrammerAnimemes • • Mar 01 '20

$(‘#i-hate-it’)

Post image
955 Upvotes

49 comments sorted by

View all comments

Show parent comment

5

u/Takeoded May 09 '20 edited May 09 '20

jQuery mantra has always (or at least since 2010) been write less, do more and that's still true today. writing $() is faster than writing document.querySelectorAll(), writing $("foo").on("click",function(){console.log(this.textContent+" clicked");}); is faster than writing

document.querySelectorAll("foo").forEach(function(ele) {
    ele.addEventListener("click", function(ele) {
        console.log(ele.target.textContent + " clicked");
    });
});
  • and so on.

jQuery's write less, do more is still true.

0

u/[deleted] May 09 '20

[deleted] — view deleted comment

4

u/Takeoded May 09 '20

loading jQuery from a CDN (like GoogleCDN, cdnjs, or jsdeliver) is cheap, while developer time isn't cheap. also jQuery is such a popular library that chances are good the browser cache already has it if you use a popular CDN.

also, minified jQuery 3.5.1 is 0.08 megabytes of code, and 0.02 megabytes gzip-compressed