jQuery append vs document.createElement

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script>
  var each = function(obj, fn) {
    for (i in obj) {
      obj.hasOwnProperty(i) && fn(obj[i], i);
    }
  };
  
  var attrs = {
    id : 'sectionMenu',
    className : 'section'
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$('<div />').attr(attrs).appendTo('body');
ready
native
var foo = document.createElement('div');
each(attrs, function(val, key) {
  foo[key] = val;
});
document.body.appendChild(foo);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.