Vanilla JS V Jquery Hide (v11)

Revision 11 of this benchmark created by Michael S. Mikowski on


The original poster declared that jQuery sucks by not testing the same thing. The show() and hide() methods are much more sophisticated than setting the CSS display property. The provide for callbacks, fades, chaining, and all sorts of capabilities. Let's try to get a little closer to an Apples-to-Apples comparison, shall we?

Yes, jQuery is slower, but not by the huge margin the obviously biased or naive or disingenuous original author. On my local workstation, jQuery is around 25% as fast as native, showing 224,870 versus 973,709 ops/s for the best native showing. Even that is not a true apples to apples comparison, however, because jQuery provides for batching of CSS parameters and provides for callbacks after the DOM has updated - a non-trivial capability that is not easily obtained cross-browser using native JS.

Preparation HTML

<div id="Stupid_Div">
  Stupid Crap
<script src="">


      $div = $('#Stupid_Div'),
      none_map  = { display: 'none' },
      block_map = { display: 'block' }

Test runner

Ready to run.

Testing in
jQuery CSS props
Vanilla JS
document.getElementById("Stupid_Div").style.display = "none";
document.getElementById("Stupid_Div").style.display = "block";
document.getElementById("Stupid_Div").style.display = "none";
Vanilla JS Retarded Suggestion
var hide = "none"; //this var isnt needed
var show = "block"; //this var isnt needed
document.getElementById("Stupid_Div").style.display = hide;
document.getElementById("Stupid_Div").style.display = show;
document.getElementById("Stupid_Div").style.display = hide;
Vanilla JS Cache-Everything Option
var hide = "none",
  show = "block",
  elem = document.getElementById("Stupid_Div"); = hide; = show; = hide;
jQuery retarded comparison


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