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
What's the fastest way to get a child in jQuery? .children(), .next() or :first-child? I know the class-name in advance.
http://www.quora.com/Whats-the-fastest-way-to-get-a-child-in-jQuery
<div id="parent" class="parent">
<div id="child" class="child">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var p = $('#parent');
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
$('#parent').children() |
| ready |
$('#parent').children('.child') |
| ready |
$('.child:first-child') |
| ready |
$('#parent .child:first-child') |
| ready |
$('#parent :first-child') |
| ready |
p.children() |
| ready |
$('#parent').children(':first') |
| ready |
$('#parent').children().first() |
| ready |
p.children().first() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.