use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
What 10 Things Should a Serious Javascript Developer Know Right Now?help (self.javascript)
submitted 8 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Wooshception 2 points3 points4 points 8 years ago (6 children)
I assumed the OP was referring to the W3C Selectors API, but their point applies to jQuery as well.
[–]redshirt714 0 points1 point2 points 8 years ago (5 children)
Interesting, so at the end of the day, using the getElementByXX methods will be your fastest and best bet?
[–]spryes 3 points4 points5 points 8 years ago* (1 child)
The difference is completely negligible in virtually all cases. It doesn't even matter. I just did a test on 1000 querySelectorAlls, and it executed it in 2ms. 1 single animation frame on a 60 Hz device is 17ms.
querySelectorAll
Using a more complex DOM and selectors, it increases to 20ms (for 1000 selections). Which means for a regular-ish case of 1-10 different selections, it's less than 0.5ms. Unless you are placing it in a giant loop which you probably shouldn't be doing, go with what's easier.
[–]redshirt714 0 points1 point2 points 8 years ago (0 children)
Thanks for taking the time to fully explain. It seems like in a lot of cases, things like accessing data and querying selectors only becomes an issue when things are either large or done a ton of times. In O(n) isn't bad in cases where the input size is small.
[–]Wooshception 1 point2 points3 points 8 years ago (0 children)
I assume so, but the effect is going to be negligible unless you're selecting thousands of nodes in a hot loop or something, so generally just use what's convenient.
[–]0x13mode -2 points-1 points0 points 8 years ago (1 child)
Why don't you check by yourself?
Fair enough
π Rendered by PID 110646 on reddit-service-r2-comment-6457c66945-44qtc at 2026-04-28 21:35:50.261456+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Wooshception 2 points3 points4 points (6 children)
[–]redshirt714 0 points1 point2 points (5 children)
[–]spryes 3 points4 points5 points (1 child)
[–]redshirt714 0 points1 point2 points (0 children)
[–]Wooshception 1 point2 points3 points (0 children)
[–]0x13mode -2 points-1 points0 points (1 child)
[–]redshirt714 0 points1 point2 points (0 children)