+ 3
What is faster - querySelector or getElementById?
5 Answers
+ 9
getElementById probably because it doesnt do any additional operations such as analysing your input.
+ 3
Try this to test the speed of each update functions, notice the speed of jQuery function.
https://code.sololearn.com/Wu20kv75u57T/?ref=app
+ 2
get ElementById- gets an element with particular I'd ,in this case it will be operable to all same ID's .
querySelector- it is operable for the first occurance of a id
+ 2
I think, querySelector is faster
+ 1
getElementById is faster but no significant. So we use whichever that convenient to us most.