Check hidden (v8)

Revision 8 of this benchmark created by Steve on


Description

Inverting the tests to check if the element is hidden rather than visible. Will short-circuit when testing both offsetParent and offsetHeight

Preparation HTML

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


<div>
    <div id="test" style="display:none">Hello there</div>
</div>

Setup

var el = document.getElementById("test");

Test runner

Ready to run.

Testing in
TestOps/sec
el.offsetParent === null
var hidden = el.offsetParent === null
ready
el.offsetHeight === 0
var hidden = el.offsetHeight === 0
ready
el.offsetParent, el.offsetHeight
var hidden = el.offsetParent === null || el.offsetHeight === 0
ready
getComputedStyle
var hidden = window.getComputedStyle(el).display === 'none'
ready
jquery
var hidden = $(el).not(':visible')
ready

Revisions

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