Bind vs. Click vs. Delegate vs. Live (v3)

Revision 3 of this benchmark created by Kyle A. Matheny on


Description

Determining whether it is faster to use click(), bind(), delegate(), or live() on click events.

Preparation HTML

<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Blog</a></li>
</ul>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
Bind
$('#nav').find('a').bind('click', function(e) {
 e.preventDefault();
});
ready
Click
$('#nav').find('a').click(function(e) {
 e.preventDefault();
});
ready
Delegate
$('#nav').delegate('a', 'click', function(e) {
 e.preventDefault();
});
ready
Live
$('#nav').find('a').live('click', function(e) {
 e.preventDefault();
});
ready

Revisions

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