Data Selector Performance

JavaScript performance comparison

Revision 23 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul id="test">
</ul>
<script>
Benchmark.prototype.setup = function() {
    var i = 500;
    var ul = $("#test");
    ul.html('');
    while (i > 0) {
      ul.append("<li data-component=\"list-item\" class=\"list-item my-other-class\">List Item " + i.toString() + "</li>");
      i -= 1;
    }
};

Benchmark.prototype.teardown = function() {
    ul.html('');
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
dataSelector
$("[data-component=\"list-item\"]", ul)
pending…
classSelector
$(".list-item", ul)
pending…
two classes
$(".list-item.my-other-class", ul)
pending…
data + class
$(".list-item[data-component=\"list-item\"]", ul)
pending…
data component only
$("[data-component]", ul)
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