all.tags - 10 matched elements with mixed contents

Benchmark created by Daniel on


Description

getElementsByTagName() vs all.tags()

Finding all elements of a given tag, 10 elements to be found, mixed content present

Preparation HTML

<div id="wrap">

<h2>This is an H2 tag</h2>

<p>This is a p tag containing text. This tag is present to provide some variance in the element content that is being queried.</p>

<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span><span>10</span>

<ul>
<li>Random list item 1</li>
<li>Random list item 2</li>
<li>Random list item 3</li>
</ul>

</div>
<script>
  var wrap = document.getElementById('wrap');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementsByTagName
wrap.getElementsByTagName('span');
ready
all.tags
wrap.all.tags('span');
ready

Revisions

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

  • Revision 1: published by Daniel on