JavaScript JavaScript and the DOM Getting a Handle on the DOM Using CSS Queries to Select Page Elements

jlampstack
jlampstack
17,755 Points

Performance?

Does querySelector use up more resources or take longer than using the other selectors getElementById, or getElementsByClassName?

I think they are more or less equally performant if you compare the right things. When you use querySelector and you do a query on a class than you should compare with getElementByClassName, if you do a query on an id, you should compare with getElementById.