Test name | Executions per second |
---|---|
createElement | 252.2 Ops/sec |
createDocumentFragment | 306.8 Ops/sec |
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);