Element traversing parents with obstacles

JavaScript performance comparison

Test case created by Orkel

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var $current = $.noConflict();
</script>
<script src="https://docs.google.com/uc?id=0B6yiDAQGhvdFZWVkNjcxZDctOWYwYS00NzdjLWFkMDUtZmM0Yjg2OTYyZjhh&export=download&hl=ru">
</script>
<script>
  var $test = $.noConflict();
</script>

<div class="parent">
  <div>
    test
  </div>
 
  <!--test -->
  <![CDATA[test]]>
  test
 
  <div>
    test
  </div>
 
  <!--test -->
  <![CDATA[test]]>
  test
 
  <div id="median">
    test
  </div>
 
  <!--test -->
  <![CDATA[test]]>
  test
 
  <div>
    test
  </div>
 
  <!--test -->
  <![CDATA[test]]>
  test
 
  <div>
    test
  </div>
 
  <!--test -->
  <![CDATA[test]]>
  test
 
</div>

<script>
  var currentDiv = $current( "div div" ),
  testDiv = $test( "div div" );
</script>

Preparation code output

test
test
test
test
test
test
test
test
test
test

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
current parents
currentDiv.parents();
pending…
test parents
testDiv.parents();
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