jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
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.
<div id="Stupid_Div">
Stupid Crap
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
var
$div = $('#Stupid_Div'),
none_map = { display: 'none' },
block_map = { display: 'block' }
;
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery CSS props |
| ready |
Vanilla JS |
| ready |
Vanilla JS Retarded Suggestion |
| ready |
Vanilla JS Cache-Everything Option |
| ready |
jQuery retarded comparison |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.