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

Revision 4 of this benchmark created on


Description

Determining whether it is faster to use click(), bind(), delegate(), or live() on click events; combining those with find() and filter() as well.

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
Live .filter()
$('#nav').filter('a').live('click', function(e) {
 e.preventDefault();
});
ready
Bind .filter()
$('#nav').filter('a').bind('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.