DOM Manipulation (v152)

Revision 152 of this benchmark created by P0lip on


Description

A small test. There is no Element.insertAdjacentHTML() method here - sorry.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div id="list" style="display:none"></div>

Setup

const list = document.getElementById("list");
    const $list = jQuery(list);

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.html()
$list.html('<div>No elo<div>Hey there!<div>Wazzup?</div></div></div>');
$list.html('<div>No elo</div>');
list.innerHTML = '';
ready
innerHTML
list.innerHTML = '<div>No elo<div>Hey there!<div>Wazzup?</div></div></div>';
list.innerHTML = '<div>No elo</div>';
list.innerHTML = '';
ready
createElement with appendChild and .textContent
var firstDiv = list.appendChild(document.createElement('div'));
firstDiv.textContent = 'No elo';
var secondDiv = firstDiv.appendChild(document.createElement('div'));
secondDiv.textContent = 'Hey there!';
var thirdDiv = secondDiv.appendChild(document.createElement('div'));
thirdDiv.textContent = 'Wazzup?';
secondDiv.remove();
firstDiv.remove();
ready
DocumentFragment
var docFragment = document.createDocumentFragment();
var firstDiv = docFragment.appendChild(document.createElement('div'));
firstDiv.textContent = 'No elo';
var secondDiv = firstDiv.appendChild(document.createElement('div'));
secondDiv.textContent = 'Hey there!';
var thirdDiv = secondDiv.appendChild(document.createElement('div'));
thirdDiv.textContent = 'Wazzup?';
secondDiv.remove();
firstDiv.remove();
list.appendChild(docFragment);
ready

Revisions

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