cost of :visible vs class

Benchmark created by JLennox on


Preparation HTML

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

<style type="text/css">
.hide { display: none; }
</style>


<div class="test-target"></div>
<div class="test-target"></div>
<div class="test-target"></div>
<div class="test-target hide"></div>
<div class="test-target hide"></div>
<div class="test-target hide"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
class
if ($(".test-target:not(.hide)").length != 3)
alert("broken test");
ready
:visible
if ($(".test-target:visible").length != 3)
alert("broken test");
ready

Revisions

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

  • Revision 1: published by JLennox on