Are semicolons faster

JavaScript performance comparison

Test case created by Tomasz Wójcik

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="container">
  <ul id="parent">
    <li class="child">
    </li>
    <li class="foo">
    </li>
    <li class="child">
    </li>
    <li class="bar">
    </li>
  </ul>
</div>

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
without
$('.child').each(function() {
  $(this).parent()
  $(this).parent()
  $(this).parent()
  $(this).parent()
  $(this).parent()
})
pending…
with
$('.child').each(function() {
  $(this).parent();
  $(this).parent();
  $(this).parent();
  $(this).parent();
  $(this).parent();
});
pending…

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

Compare results of other browsers

0 comments

Add a comment