On click performance

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="main">
  <button id="click1">
  </button>
  <button id="click2">
  </button>
  <button id="click2">
  </button>
</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
Test 1
$('#main').on("click", "#child1", function() {
  alert('hi');
}).on("click", "#child2", function() {
  alert('hi');
}).on("click", "#child3", function() {
  alert('hi');
});
pending…
Test 2
var $ctx = $('#main');

$ctx.find('#click1').click(function() {
  alert('hi');
});
$ctx.find('#click2').click(function() {
  alert('hi');
});
$ctx.find('#click3').click(function() {
  alert('hi');
});
pending…
Test 3
$('#main').on("click", "#child-1, #child-2, #child-3", function() {
  alert('hi');
});
pending…
Test 4
var $ctx = $('#main');

$ctx.find('#click1').click(function() {
  alert('hi');
}).find('#click2').click(function() {
  alert('hi');
}).find('#click3').click(function() {
  alert('hi');
});
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