jQuery vs. Vanilla: 3 - DOM manipulation (add content)

JavaScript performance comparison

Test case created

Info

Some jQuery vs Vanilla tests based on Craig Bucklers article Native JavaScript Equivalents of jQuery Methods: the DOM and Forms.

Preparation code

<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>

<ul id="comments">
    <li class="comment">1</li>
    <li class="comment">2</li>
    <li class="comment">3</li>
    <li class="comment">4</li>
    <li class="comment">5</li>
    <li class="comment">6</li>
    <li class="comment">7</li>
    <li class="comment">8</li>
    <li class="comment">9</li>
    <li class="comment">10</li>
    <li class="comment">11</li>
    <li class="comment">12</li>
</ul>

Preparation code output

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery 2.0 append
$("#comments").append('<li style="display: none">13</li>');
pending…
vanilla innerHtml
document.getElementById("comments").innerHTML += '<li style="display: none">13</li>';
pending…
vanilla DOM building
var li = document.createElement("li");
li.style.display = "none";
li.appendChild(document.createTextNode("13"));
document.getElementById("comments").appendChild(li);
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