jQuery find() vs find().filter() with attribute selector (v2)

Revision 2 of this benchmark created on


Description

What's the difference in performance between:

$("div[data-num='300']");

and

$("div").filter("[data-num='300']");

Preparation HTML

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

<script>

for (var i = 0; i < 500; i++) {
document.write("<div data-num='" + i + "'>" + i + "</div>\n");
}

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
$("div[data-num='300']")
$("div[data-num='300']");
ready
$("div").filter("[data-num='300']")
$("div").filter("[data-num='300']");
ready

Revisions

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