xpath evaluate vs. querySelector -- Attribute selector

JavaScript performance comparison

Revision 65 of this test case created by Cory

Preparation code

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

Preparation code output

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

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
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.

0 Comments

Foo

Bar

Baz