Vanilla JS V Jquery Hide

JavaScript performance comparison

Revision 11 of this test case created by Michael S. Mikowski

Preparation code

<div id="Stupid_Div">
  Stupid Crap
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var
    $div = $('#Stupid_Div'),
    none_map  = { display: 'none' },
    block_map = { display: 'block' }
    ;

};
</script>

Preparation code output

<div id="Stupid_Div"> Stupid Crap </div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jQuery CSS props
$div.css(none_map).css(block_map).css(none_map);
pending…
Vanilla JS
document.getElementById("Stupid_Div").style.display = "none";
document.getElementById("Stupid_Div").style.display = "block";
document.getElementById("Stupid_Div").style.display = "none";
pending…
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;
pending…
Vanilla JS Cache-Everything Option
var hide = "none",
  show = "block",
  elem = document.getElementById("Stupid_Div");
elem.style.display = hide;
elem.style.display = show;
elem.style.display = hide;
pending…
jQuery retarded comparison
$('#Stupid_Div').hide().show().hide();
pending…

Compare results of other browsers

Revisions

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

0 Comments

Stupid Crap