jquery hover vs delegate

Benchmark created on


Preparation HTML

<table id="table">
  <tr>
    <th>
      foo
    </th>
    <th>
      bar
    </th>
  </tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
delegate
$('#table').delegate("th", "mouseover mouseout", function(event) {
  if (event.type == "mouseover") $(this).css("background-color", "yellow");
  else $(this).css("background-color", "yellow");
});
ready
hover
$('#table').find("th").hover(function(event) {
  $(this).css("background-color", "yellow");
}, function(event) {
  $(this).css("background-color", "yellow");
});
ready

Revisions

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