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

Revision 2 of this benchmark created on


Description

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

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function handler() {
        $('p').text("CLICK !");
}
</script>
<p>Event</p>

Test runner

Ready to run.

Testing in
TestOps/sec
.bind
$('p').bind('click', handler);
ready
.live() in document
$('p').live('click', handler);
ready
.live() in a
$('p', $(document)[0]).live('click', handler);
ready
.delegate
$(document).delegate('p', 'click', handler);
ready
.on
$(document).on('click', 'p', handler);
ready

Revisions

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