- From: Glen Huang <curvedmark@gmail.com>
- Date: Mon, 27 Apr 2015 16:57:23 +0800
- To: public-webapps <public-webapps@w3.org>
Received on Monday, 27 April 2015 08:57:56 UTC
Intuitively, querySelector('.class') only needs to find the first matching node, whereas getElementsByClassName('.class')[0] needs to find all matching nodes and then return the first. The former should be a lot quicker than the latter. Why that's not the case? See http://jsperf.com/queryselectorall-vs-getelementsbytagname/119 <http://jsperf.com/queryselectorall-vs-getelementsbytagname/119> for the test I know querySelectorAll is slow because of the static nature of returned NodeList, but this shouldn't be an issue for querySelector.
Received on Monday, 27 April 2015 08:57:56 UTC