testing for empty ul

Benchmark created by Eric Pascarello on


Description

Test if a UL is empty [has no child elements] with jQuery

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="foo">
    <ul></ul>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
empty selector
var isEmpty = jQuery("#foo ul:empty").length === 0;
ready
li selector
var isEmpty = jQuery("#foo ul li").length === 0;
ready
html length
var isEmpty = jQuery("#foo ul").html().length === 0;
ready

Revisions

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

  • Revision 1: published by Eric Pascarello on