adding dom elements jquery vs mootools vs dojo to body

JavaScript performance comparison

Revision 10 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/prototype/1/prototype.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js">
</script>
<script>
  require(["dojo/dom-construct"], function(domConstruct) {
    window.domConstruct = domConstruct;
  });
</script>
<div id="container">
</div>
<script>
Benchmark.prototype.setup = function() {
    containerNode = document.getElementById('container');
};

Benchmark.prototype.teardown = function() {
    document.getElementById('container').innerHTML = '';
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
dojo
dojo.create('div', {
  id: 'myElement',
  innerHTML: 'This is a new element'
}, containerNode);
pending…
jquery
jQuery("<div>", {
  "id": "myElement"
}).html("This is a new element").appendTo(containerNode);
pending…
mootools
new Element('div', {
  id: 'myElement',
  text: 'This is a new element'
}).inject(containerNode);
pending…
dojo 1.7 AMD
domConstruct.create('div', {
  id: 'myElement',
  innerHTML: 'This is a new element'
}, containerNode);
pending…
ECMAScript
var div = document.createElement('div');
div.id = 'myElement';
div.innerHTML = 'This is a new element';
containerNode.appendChild(div);
pending…
Using with block
'use strict';

var div = document.createElement('div');

with(div) {
  id = 'myElement';
  innerHTML = 'This is a new element';
}

containerNode.appendChild(div);
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