CheckboxTests

JavaScript performance comparison

Test case created

Preparation code

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

<input type="checkbox" name="checkbox0" id="id0">
<input type="checkbox" name="checkbox1" id="id1" checked>
<input type="checkbox" name="checkbox2" id="id2">
<input type="checkbox" name="checkbox3" id="id3" checked>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
attr
return $('input[checked]').length > 0;
pending…
is
return $('input').is(':checked');
 
pending…
native
var checked = false;

$('input').each(function() {
  if ($(this).checked) {
    checked = true;
  }
});
return checked;
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. Here’s a list of current revisions for this page:

0 comments

Add a comment