rmesserle: DollarDom vs jQuery (v2)

Revision 2 of this benchmark created 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);
  
  ( function ( $ ) {
        $.dom_nocache = function ( str, obj ) {
                var id, $ret = $( document.createElement( str ) );
                if ( obj ) for ( id in obj ) if ( $ret[ id ] ) $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'
  },
  bind: {
    click: function() {
      alert('hi');
    }
  }
});
ready
dollarDom (nocache)
$.dom_nocache('div', {
  attr: {
    'class': 'holy_smokes'
  },
  css: {
    color: 'red'
  },
  bind: {
    click: function() {
      alert('hi');
    }
  }
});
ready

Revisions

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