:visible vs .is(visible)

JavaScript performance comparison

Test case created by Matt

Preparation code

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

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

    

Preparation code output

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
:visible
$("#test:visible")
pending…
.is(":visible")
$("#test").is(":visible")
pending…

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

1 Comment

Matt R. commented :

is(":visible") is suprinsingly faster. I thought they used the same backend. I guess string parsing is more resource intensivw than i thought