find().on() vs .on()

JavaScript performance comparison

Revision 13 of this test case created

Info

The Difference Between [context].find([selector]).on([event]) and [context].on([event], [selector])

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  function handler() {
    // Do something
    temp += Math.random() / Math.random() / Math.random();
  }
  var $context = $('#context'),
    $p = $context.find('p'),
    temp;
  ui.benchmarks[0].setup = function() {
    temp = 0;
    $context.on('click', 'p', handler);
  };
  ui.benchmarks[1].setup = function() {
    temp = 0;
    $context.find('p').on('click', handler);
  };
</script>
<div id="context">
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>verylongcontents</p>
  <p>Event test</p>
</div>

Preparation code output

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

verylongcontents

Event test

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
.on() in context
$p.trigger('click');
pending…
.find().on()
$p.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. Here’s a list of current revisions for this page:

0 comments

Add a comment