jQuery 2.1.4 - prop('checked') vs. is(':checked') vs. checked

JavaScript performance comparison

Revision 78 of this test case created by

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<input type="checkbox" value="n" name="my-test-checkbox-n" id="my-test-checkbox-n">
<input type="checkbox" value="y" name="my-test-checkbox-y" id="my-test-checkbox-y" checked>

<script>
  var $elUnchecked = $('#my-test-checkbox-n');
  var $elChecked = $('#my-test-checkbox-y');
</script>
    

Preparation code output

<input type="checkbox" value="n" name="my-test-checkbox-n" id="my-test-checkbox-n"> <input type="checkbox" value="y" name="my-test-checkbox-y" id="my-test-checkbox-y" checked> <script> var $elUnchecked = $('#my-test-checkbox-n'); var $elChecked = $('#my-test-checkbox-y'); </script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
attr("checked") - Checked - Sync test
$elChecked.attr("checked");
pending…
.prop() - Checked - Sync test
$elChecked.prop('checked');
pending…
.prop() - Checked - Async test
// async test
$elChecked.prop('checked');
pending…
.prop() - Unchecked - Sync test
$elUnchecked.prop('checked');
pending…
.prop() - Unchecked - Async test
// async test
$elUnchecked.prop('checked');
pending…
.is(':checked') - Checked - Sync test
$elChecked.is(':checked');
pending…
.is(':checked') - Checked - Async test
// async test
$elChecked.is(':checked');
pending…
.is(':checked') - Unchecked - Sync test
$elUnchecked.is(':checked');
pending…
.is(':checked') - Unchecked - Async test
// async test
$elUnchecked.is(':checked');
pending…
attr("checked") - Checked - Async test
// async test
$elChecked.attr("checked");
pending…
attr("checked") - Unchecked - Sync test
$elUnchecked.attr("checked");
pending…
attr("checked") - Unchecked - Async test
// async test
$elUnchecked.attr("checked");
pending…
.checked - Checked - Sync test
$elChecked[0].checked;
pending…
.checked - Checked - Async test
// async test
$elChecked[0].checked;
pending…
.checked - Unchecked - Sync test
$elUnchecked[0].checked;
pending…
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.

0 Comments