jquery hide

Benchmark created by Thomas Genin on


Description

What is the fastest way to hide an element but to keep it in the DOM ?

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style>
.hide{
display: none;
}
</style>
<div id=elem>Hello</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery Hide
$("#elem").hide();
ready
jQuery css
$("#elem").css('display', 'none');
ready
jQuery css object
$("#elem").css({'display':'none'});
ready
js
document.getElementById('elem').style.display = 'none';
ready

Revisions

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

  • Revision 1: published by Thomas Genin on
  • Revision 2: published by Thomas Genin on