.bind() vs .live() vs .delegate() vs .on() (v7)

Revision 7 of this benchmark created on


Description

The Difference Between Zepto’s .bind(), .live(), .on() and .delegate()

Preparation HTML

<script src="https://zeptojs.com/zepto.min.js"></script>
<script>
  function handler() {
    $('p').text("CLICK !");
  }
</script>
<div id="context">
<div>
<p>Event test</p>
</div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
.bind
$('p').bind('click', handler);
ready
.live() in document
$('p').live('click', handler);
ready
.delegate
$(document).delegate('p', 'click', handler);
ready
.on
$(document).on('click', 'p', handler);
ready
.bind() in context
$('p', $('#context')).bind('click', handler);
ready
.live() in context
$('p', $('#context')).live('click', handler);
ready
.delegate() in context
$('#context').delegate('p', 'click', handler);
ready
.on() in context
$('#context').on('click', 'p', handler);
ready
.on() common
$('p').on('click', handler);
ready

Revisions

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