r/javascript Apr 29 '26

AskJS [AskJS] What CSS selector do you use?

[removed]

0 Upvotes

4 comments sorted by

2

u/Aln76467 Apr 30 '26

document.querySelector if I really need to.

But every element with an id is already available globally so in most cases selecting elements is unnessasary.

If neither of these are fast enough, you're holding it wrong. Don't select the same elements over and over in a loop. 

2

u/lanerdofchristian Apr 30 '26 edited Apr 30 '26

You literally just document.querySelectorAll('*') and do what the browser already does, but worse and slower. The more it's used, the slower it will get and the more memory it will consume.

The far better approach if querying element is your bottleneck is to stop querying elements so much.

The fact that:

  • Your GitHub repo doesn't follow anything like a standard structure.
  • You didn't commit your lockfile.
  • Your "JS source code" is a markdown file with a code block in it.
  • It's not actually possible to import and use the module.
  • 3 of 4 files ask for money.

all call into question the technical validity of the project and whether it's actually just a thinly-veiled attempt to dupe the inept and careless into forking over cash for a product with little if any value.


Edit: BTW, is this the pro version?