jQuery click vs bind vs on (v11)

Revision 11 of this benchmark created on


Description

Tests performance of jQuery event listeners.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

<div id="main">
</div>

Setup

var $main = $('#main');

Test runner

Ready to run.

Testing in
TestOps/sec
click
$("#main").click(function() {});
ready
bind
$("#main").bind("click", function() {});
ready
on
$("#main").on("click", function() {});
ready
onclick
document.getElementById("main").onclick = function() {};
ready
on - cached selctor
$main.on("click", function() {});
ready
click - cached selector
$main.click(function() {});
ready
bind - cached selector
$main.bind("click", function() {});
ready

Revisions

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