hover vs mouseenter
JavaScript performance comparison
Test case created by Matt Mannello
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul id="leftNav">
<li class="selected">
<ul class="leftSubNav">
<li><a href="#">test</a></li>
</ul>
</li>
</ul>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Testing in unknown unknown
| Test |
Ops/sec |
live mouseenter mouseleave |
/* set up hover functionality in subnav */ $('ul#leftNav li.selected ul.leftSubNav li:not([class*="selected"]) a').live('mouseenter mouseleave', function(e) { if (e.type == 'mouseover') { $(this).animate({ left: '5px' }, 100); } else { $(this).animate({ left: '0px' }, 100) } });
|
pending… |
mouseenter mouseleave |
$('ul#leftNav li.selected ul.leftSubNav li:not([class*="selected"]) a').mouseenter(
function() { $(this).animate({ left: '5px' }, 100); }).mouseleave(
function() { $(this).animate({ left: '0px' }, 100) });
|
pending… |
hover |
$('ul#leftNav li.selected ul.leftSubNav li:not([class*="selected"]) a').hover(
function() { $(this).animate({ left: '5px' }, 100); }, function() { $(this).animate({ left: '0px' }, 100); });
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
Compare results of other browsers
0 comments