jQuery find() vs find().filter() with :checked (v13)

Revision 13 of this benchmark created by patricia on


Description

What's the difference in performance between:

$("input:checked");

and

$("input").filter(":checked");

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("<input type='checkbox' checked='checked' />");
document.write("<input type='checkbox' />");

}

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
$("input:checked");
$("input:checked");
ready
$("input").filter(":checked");
$("input").filter(":checked");
ready
with var
var $tmp = $("div");
$tmp.filter("[data-num='300']");
ready
$find()
$.find("div[data-num='300']");
ready
[data-num='300']
$("[data-num='300']");
ready
find([data-num='300'])
$.find("[data-num='300']");
ready

Revisions

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