Hacker News new | ask | show | jobs
by dspillett 1367 days ago
> Is there a reason to not use querySelector

getElement is slightly faster, but not by enough to care IIRC so I use querySelector for consistency and it's flexibility.

> One reason jQuery became so popular is because the DOM was painful

I would say that is the key reason, with everything else being collateral benefits. Assuming you combine element selection, dealing with legacy incompatibilities, and function chaining to reduce boilerplate code, under the same banner of "making the DOM less painful".

1 comments

...and portability.
Between browsers?

I was counting that in "dealing with legacy incompatibilities".