When using JavaScript in the web browser is there any performance difference between the following:
Existing getElementById
document.getElementById(elem);
Query Selector using #id
document.querySelector(#elem);
Query Selector using [id=elem]
document.querySelector([id=elem]);
I'm assuming the first one will be fastest (only has to lookup elements with an ID). Also the final one looks like bad practice. I like the second one as using querySelector for everything makes the code easy to read.
Any suggestions?