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

JavaScript performance comparison

Revision 98 of this test case created by Gemorroj

Preparation code

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

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

      
<script>
Benchmark.prototype.setup = function() {
  $y = $("#my-test-checkbox-y");
  $n = $("#my-test-checkbox-n");
  

};
</script>

Preparation code output

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

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
is checked n
$n.is(":checked");
pending…
prop checked n
$n.prop("checked");
pending…
is checked y
$y.is(":checked");
pending…
prop checked y
$y.prop("checked");
pending…

Revisions

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

0 Comments