Browser dom speed tests
JavaScript performance comparison
Info
Tests to see what speeds the browser DOM runs at in various browsers.
DOM Core Performance: Appending, Prepending, Inserting, Indexing, Removing
InnerHTML
Preparation code
<div></div>
<script>
var count = 100;
var divs = new Array(count);
var div = document.getElementsByTagName('div')[0]
function testAppend(div) {
var add = document.createElement('div');
for (var i = 0; i<=1000;i++) {
div.appendChild(add);
}
}
function testPrepend(div) {
var add = document.createElement('div');
for (var i = 0; i<=1000;i++) {
div.insertBefore(add, div.firstChild);
}
}
function testInnerHTML(div) {
for (var i = 0; i<=1000;i++) {
div.innerHTML = "<div></div>";
}
}
function testInnerHTMLBuffer(div) {
var buffer=[];
for (var i = 0; i<=1000;i++) {
buffer.push("<div></div>")
}
div.innerHTML = buffer.join("");
}
function testInsert(div) {
var add = document.createElement('div');
for (var i = 0; i<=1000;i++) {
div.insertBefore(add, div[0]);
}
}
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Append |
|
pending… |
innerHTML |
|
pending… |
Prepend |
|
pending… |
Insert |
|
pending… |
innerHTML + buffer |
|
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:
- Revision 1: published
- Revision 3: published
- Revision 4: published by Brigitte Jellinek
- Revision 5: published
- Revision 6: published
- Revision 7: published
0 comments