On Maze

JavaScript performance comparison

Test case created by Josh

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="home-menu">
  <ul>
    <li id="home-nav">
      <a href="/" class="home-link other-link"><img src="/img/transparent.png" class="home-nav-house" alt="Cynergy. The Experience Agency" width="26" height="25"></a>
    </li>
    <li id="http://jsperf.com/on-mazing">
      <a href="/who_we_are/" class="other-link"><strong>WHO</strong> WE ARE</a>
    </li>
    <li id="what-we-do-nav">
      <a href="/what_we_do/" class="other-link"><strong>WHAT</strong> WE DO</a>
    </li>
    <li id="how-we-do-it-nav">
      <a href="/how_we_do_it/" class="other-link"><strong>HOW</strong> WE DO IT</a>
    </li>
    <li id="our-work-nav">
      <a href="/our_work/" class="other-link">OUR <strong>WORK</strong></a>
    </li>
    <li id="contact-nav">
      <a href="/contact/" class="other-link"><strong>CONTACT</strong> US</a>
    </li>
  </ul>
</div>
      
<script>
Benchmark.prototype.setup = function() {
  b = 0;
  a = function() {
    b += 1;
  }
  $('div#home-menu').on('click', '#contact-nav .other-link', a);
  $('.home-link').on('click', a);
  
  $('div#home-menu ul li#who-we-are-nav a.other-link').on('click', a);
  

};
</script>

Preparation code output

<div id="home-menu"> <ul> <li id="home-nav"> <a href="/" class="home-link other-link"><img src="/img/transparent.png" class="home-nav-house" alt="Cynergy. The Experience Agency" width="26" height="25"></a> </li> <li id="http://jsperf.com/on-mazing"> <a href="/who_we_are/" class="other-link"><strong>WHO</strong> WE ARE</a> </li> <li id="what-we-do-nav"> <a href="/what_we_do/" class="other-link"><strong>WHAT</strong> WE DO</a> </li> <li id="how-we-do-it-nav"> <a href="/how_we_do_it/" class="other-link"><strong>HOW</strong> WE DO IT</a> </li> <li id="our-work-nav"> <a href="/our_work/" class="other-link">OUR <strong>WORK</strong></a> </li> <li id="contact-nav"> <a href="/contact/" class="other-link"><strong>CONTACT</strong> US</a> </li> </ul> </div>

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
Simple on
$('#home-nav .other-link').trigger('click');
pending…
complex on
$('#what-we-do-nav .other-link').trigger('click');
pending…
delegated on
$('#home-menu .other-link').trigger('click');
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