Data Selector Performance (v35)

Revision 35 of this benchmark created on


Preparation HTML

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

Setup

var i = 500;

Test runner

Ready to run.

Testing in
TestOps/sec
dataSelector (variable)
while (i > 0) {
  $("[data-component=\"i" + i + "\"]", ul)
  i -= 1;
}
ready
classSelector (variable)
while (i > 0) {
  $(".i" + i, ul)
  i -= 1;
}
ready
two classes (variable + fixed)
while (i > 0) {
  $(".my-other-class.i" + i, ul)
  i -= 1;
}
ready
classSelector (fixed)
while (i > 0) {
  $(".my-other-class", ul)
  i -= 1;
}
ready

Revisions

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