Data Selector Performance (v17)

Revision 17 of this benchmark created by Adina on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div>
<ul id="test">
</ul>
<ul id="test-two">
</ul>
</div>

Setup

var i = 500;
    var ul = $("#test");
    var ul2 = $("#test-two");
    var div = $("div");
    ul.html('');
    ul2.html('');
    while (i > 0) {
      ul.append("<li data-component=\"list-item\" class=\"list-item my-other-class\">List Item " + i.toString() + "</li>");
      ul2.append("<li>List Item " + i.toString() + "</li>");
      i -= 1;
    }

Teardown


    ul.html('');
    ul2.html('');
  

Test runner

Ready to run.

Testing in
TestOps/sec
dataSelector
$("li[data-component=\"list-item\"]", ul)
ready
classSelector
$(".list-item", ul)
ready
elementSelector
$("ul:first-child li", div)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.