live-vs-on

Benchmark created by Antti Ahti on


Description

Comparison of jQuery live() and on() methods when binding to the same event on multiple elements.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul>
  <li>one</li>
  <li>two</li>
  <li>three</li>
  <li>four</li>
  <li>five</li>
  <li>six</li>
  <li>seven</li>
  <li>eight</li>
  <li>nine</li>
  <li>ten</li>
</ul>

Setup

var update = function(e) {
        $(this).html('foo');
        }

Test runner

Ready to run.

Testing in
TestOps/sec
live()
$('ul li').live('click', update);
ready
on
$('ul').on('click', 'li', update);
ready

Revisions

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