html string vs createElement

JavaScript performance comparison

Revision 66 of this test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
html string
var days = [
  {
    "url": "/day/2012-11-27",
    "date": "2012-11-27"
  },
  {
    "url": "/day/2012-11-28",
    "date": "2012-11-28"
  },
  {
    "url": "/day/2012-11-29",
    "date": "2012-11-29"
  }
];


var container = document.createElement('div')
container.innerHTML = '<ul><li><a href="/day/2012-11-27">2012-11-27</a></li><li><a href="/day/2012-11-28">2012-11-28</a></li><li><a href="/day/2012-11-29">2012-11-29</a></li></ul>';




document.body.appendChild(container);
pending…
createelement
var days = [
  {
    "url": "/day/2012-11-27",
    "date": "2012-11-27"
  },
  {
    "url": "/day/2012-11-28",
    "date": "2012-11-28"
  },
  {
    "url": "/day/2012-11-29",
    "date": "2012-11-29"
  }
];
var container = document.createElement('div')
var ul = document.createElement('ul')
for (var day in days) {
  var li = document.createElement('li');
  var a = document.createElement('a');
  a.href = days[day].url
  a.textContent = days[day].date;
  li.appendChild(a);
  ul.appendChild(li);
}
container.appendChild(ul);

document.body.appendChild(container);
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