rmesserle: DollarDom vs jQuery

Benchmark created by Robert Messerle on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  (function($) {
    var cache = {};
    $.dom = function(str, obj) {
      var $ret;
      if (cache[str]) $ret = cache[str].clone();
      else cache[str] = $ret = $(document.createElement(str));
      if (obj) for (id in obj) $ret[id](obj[id]);
      return $ret;
    };
  })(jQuery);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$('<div />', {
  text: 'howdy',
  'class': 'holy_smokes',
  css: {
    color: 'red'
  },
  click: function() {
    alert('hi');
  }
})
ready
dollarDom
$.dom('div', {
  attr: {
    'class': 'holy_smokes'
  },
  css: {
    color: 'red'
  },
  events: {
    click: function() {
      alert('hi');
    }
  }
});
ready

Revisions

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