Why is getElementsByTagName() faster that querySelectorAll()? - 4 views
-
Thomas Bassetto on 29 Sep 10getElementsByTagName("a") is faster than querySelectorAll("a") in nearly all browsers. There's one very important difference between these two methods, and it's not that one accepts only a tag name and the other accepts a full CSS selector. The big difference is in the return value: the getElementsByTagName() method returns a live NodeList while querySelectorAll() returns a static NodeList. This is extremely important to understand.