Test name | Executions per second |
---|---|
createElement | 1320.8 Ops/sec |
createDocumentFragment | 1462.4 Ops/sec |
document.body.innerHTML = "";
var root = document.createElement("div");
document.body.appendChild(root);
for (var i = 0; i < 1000; i++) {
var e = document.createElement("span");
e.innerText = i + " text";
root.appendChild(e);
}
var frag = document.createDocumentFragment();
var root = document.createElement("div");
for (var i = 0; i < 1000; i++) {
var e = document.createElement("span");
e.innerText = i + " text";
root.appendChild(e);
}
document.body.appendChild(frag);