jquery element in dom

JavaScript performance comparison

Revision 10 of this test case created by Marek

Preparation code

<div id="element" class="uid_1234">
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var el = $("#element");
    var cl = $(".uid_1234");
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
offser:visible
el[0].offsetWidth !== 0 || el[0].offsetHeight !== 0;
pending…
object
el.closest(document.documentElement);
pending…
visible
el.is(":visible");
pending…
closest html
el.closest("html");
pending…
jqConains
jQuery.contains(document.documentElement, el[0])
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment