jquery-delegate-peformance

JavaScript performance comparison

Test case created by grmn

Preparation code

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js"></script>

<ul></ul>

<script>
var $ul = $('ul');
for(var i = 0; i < 100; i++) {
    $ul.append('<li>hoge</li>');
}
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var $ul = $('ul');
  var $li = $('ul li');
  

};

Benchmark.prototype.teardown = function() {
  $ul.off();
  $li.off();

};
</script>

Preparation code output

<ul></ul> <script> var $ul = $('ul'); for(var i = 0; i < 100; i++) { $ul.append('<li>hoge</li>'); } </script>

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
delegate
$ul.on('click', 'li', function(e) { 
    console.log('delegate');
});
pending…
bind
$li.on('click', function(e) { 
    console.log('bind');
});
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