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
Testing the performance of jquery objects stored in a global object, local variables, and referred to from any function vs calling the jQuery selector each time. Note that the global variables test has NO jQuery calls, and hence why it beats local variables. This is the best set up, since in real run time, the global variables would only be assigned once and never run again while locally defined variables would be run each time the function is called.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div class="myElement">
Hello World Here's Some Text
</div>
<div>
<div class="myElement"> Hello, here's some more text</div>
<div>
<div class="myElement"> Ahh, don't you love this double nested text</div>
</div>
</div>
var GL_VARS = {
desktopLoaded: false,
mobileLoaded: false,
navBarToggled: false,
toggleSpeed: 300,
currentWidth: 0,
currentHeight: 0,
myElement: $(".myElement")
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Selector Each Time |
| ready |
Globally Referred |
| ready |
Locally Reffered |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.