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

Revision 15 of this benchmark created by art on


Description

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

Preparation HTML

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

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.