jQuery: css-display:none vs. hide (v5)

Revision 5 of this benchmark created on


Description

Testing on multiple elements

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div><div></div><div></div>
<script>
var cachedjQuery = $('div');
var cachedEl = document.getElementsByTagName("div");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery :: display: none
$("div").css("display", "none");
ready
jQuery :: hide()
$("div").hide();
 
ready
jQuery :: display: none (cached)
cachedjQuery.css("display", "none");
 
ready
jQuery :: hide() (cached)
cachedjQuery.hide();
ready
Element (cached)
var i;
for(i = 0; cachedEl[i]; i++){
    cachedEl[i].style.display = "none";
}
ready
Element (cached style visibility)
var i;
for(i = 0; cachedEl[i]; i++){
    cachedEl[i].style.visibility = "hidden";
}
ready

Revisions

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