SelectorOptimization

JavaScript performance comparison

Test case created

Preparation code

<div id="one">
  <input type="radio" value="x" name="group">
  <input type="radio" value="y" name="group">
  <input type="radio" value="z" name="group">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

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
1-1
var value = "";
$("#one input:radio[name=group]").each(function() {
  if ($(this).is(":checked")) {
    value = $(this).val();
  }
});
pending…
1-2
var value = $("#one input:radio[name=group]:checked").val();
pending…
2-1
$("input:radio").filter("[value=y]").attr('checked', true);
pending…
2-2
$("#one input:radio[name=group]").filter("[value=y]").attr('checked', true);
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