xpath evaluate vs. querySelector -- Attribute selector

JavaScript performance comparison

Revision 65 of this test case created by Cory

Info

Compare the speed of xpath evaluate to querySelector on attribute selection

Preparation code

<p title="foo">Foo</p>
<p title="bar">Bar</p>
<p title="baz">Baz</p>

Preparation code output

Foo

Bar

Baz

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
xpath evaluate
var bar = document.evaluate("//*[@title='bar']",document,null,9,null).singleNodeValue;
pending…
querySelector
var bar = document.querySelector('[title="bar"]');
pending…
xpath evaluate (firefox id function)
var bar = document.evaluate("title('bar')",document,null,9,null).singleNodeValue;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment