loading...

re: Use $ & $$ Instead of document.querySelector/All in JavaScript without jQuery VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Instead of using 2 different constants, what about checking the length of the selector first like this: const $ = s => document.querySelectorA...
 

From a performance perspective, that would double the amount of work for every selector. Going from jQuery to Vanilla JS is mostly about being more performant, so that looks like an anti-pattern.

 

Can you explain how would that be the double amount of work? It's just one extra call.

It's 2 calls instead of one, so it's double.

Code of Conduct Report abuse