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
I want to find out what happens with different selectors comparing elements, classes and ids.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="a" class="a">
<p id="p" class="p"></p>
</div>
$('#a #p');
$('#a p');
$('#a .p');
$('div #p');
$('div p');
$('div .p');
$('.a #p');
$('.a p');
$('.a .p');
$('#a').find('#p');
$('#a').find('p');
$('#a').find('.p');
$('div').find('#p');
$('div').find('p');
$('div').find('.p');
$('.a').find('#p');
$('.a').find('p');
$('.a').find('.p');
Ready to run.
Test | Ops/sec | |
---|---|---|
$('#a #p'); |
| ready |
$('#a p'); |
| ready |
$('#a .p'); |
| ready |
$('div #p'); |
| ready |
$('div p'); |
| ready |
$('div .p'); |
| ready |
$('.a #p'); |
| ready |
$('.a p'); |
| ready |
$('.a .p'); |
| ready |
$('#a').find('#p'); |
| ready |
$('#a').find('p'); |
| ready |
$('#a').find('.p'); |
| ready |
$('div').find('#p'); |
| ready |
$('div').find('p'); |
| ready |
$('div').find('.p'); |
| ready |
$('.a').find('#p'); |
| ready |
$('.a').find('p'); |
| ready |
$('.a').find('.p'); |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.