jquery element in dom (v12)

Revision 12 of this benchmark created by Sev on


Preparation HTML

<div id="element"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

Setup

var el = $("#element");

Test runner

Ready to run.

Testing in
TestOps/sec
selector
el.closest("html").length;
ready
object
el.closest(document.documentElement).length;
ready
jQuery.contains
jQuery.contains(document.documentElement, el[0])
ready
Native
var p = el[0]; while (p.parentNode) p = p.parentNode; p === document;
ready

Revisions

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