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
Fastest way get a jQuery object of a DOM element of which I have the ID. document.getElementById has the advantage of not requiring escaping for special characters.
<div id="el1" class="el8">
<div id="el2" class="el7">
</div>
<div id="el3" class="el6">
<div id="el4" class="el5">
Some HTML element
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
$('#el4').length; |
| ready |
$('.el5').length; |
| ready |
$('#el1 #el3 #el4').length; |
| ready |
$('#el1 #el3 .el5').length; |
| ready |
$('#el3 .el5').length; |
| ready |
$('#el3 #el4').length; |
| ready |
$('.el8 .el7 .el6 .el5').length; |
| ready |
$(document.getElementById('el4')).length; |
| ready |
$('.el6 .el5').length; |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.