selector + javascript selector javascript - Can I access DOM element directly by id? - Stack OverflowIn javascript I always use docuemtn.getElementById to access DOM elements, but recently I accidentally accessed it using id only and it worked. Example: <input id="element_id" type="text"> ... wono | comment (1) | tweet + javascript selector performance JavaScript Selector Performance | Go Make ThingsOne of the students in my Vanilla JS Slack channel asked me about the performance difference between querySelector() and things like getElementById() and getElementsByClassName(). Specifically, getElementById() and getElementsByClassName() are more than twice as fast as querySelector() and querySelectorAll(). So, that’s bad, right? I honestly don’t think it matters. getElementById() can run about 15 million operations a second, compared to just 7 million per second for querySelector() in the latest version of Chrome. wono | discuss | tweet
+ javascript selector javascript - Can I access DOM element directly by id? - Stack OverflowIn javascript I always use docuemtn.getElementById to access DOM elements, but recently I accidentally accessed it using id only and it worked. Example: <input id="element_id" type="text"> ... wono | comment (1) | tweet
+ javascript selector performance JavaScript Selector Performance | Go Make ThingsOne of the students in my Vanilla JS Slack channel asked me about the performance difference between querySelector() and things like getElementById() and getElementsByClassName(). Specifically, getElementById() and getElementsByClassName() are more than twice as fast as querySelector() and querySelectorAll(). So, that’s bad, right? I honestly don’t think it matters. getElementById() can run about 15 million operations a second, compared to just 7 million per second for querySelector() in the latest version of Chrome. wono | discuss | tweet