Andrey's jQuery Traversal

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


<div id="vacations">
    <ul>
        <li>One</li>
        <li>Two</li>
        <li>Three</li>
        <li>Four</li>
        <li>Five</li>
        <li>Six</li>
    </ul>
</div>
<script>
Benchmark.prototype.setup = function() {
    var slice = [].slice;
};
</script>

Preparation code output

  • One
  • Two
  • Three
  • Four
  • Five
  • Six

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery Selector String
$("#vacations li:last")
pending…
jQuery Chained Selectors
$("#vacations").find("li").last()
pending…
jQuery Native Selector
$("#vacations li:last-child")
pending…
querySelector
document.querySelector("#vacations li:last-child")
pending…
querySelectorAll
document.querySelectorAll("#vacations li:last-child")
pending…
DOM
slice.call(document.getElementById("vacations").getElementsByTagName("li"), -1);
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