jQuery :empty vs filter()

Benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
Only not empty div
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div> 
<div class="philosophy-bubble">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery filter()
//div's with a certain class
$('.philosophy-bubble').filter(function() {
        return $.trim($(this).text()) === ''
}).hide()
ready
jQuery :empty
$('.philosophy-bubble:empty').hide();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.