getElementById : My.js vs jQuery vs Dojo vs ExtJS vs Native (v22)

Revision 22 of this benchmark created by Alireza on


Description

Compare perf when getting an element by id with Dojo, jQuery, ExtJS, My.js, native implementation and native implementation with cache.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojo/dojo.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js"></script>
<script type="text/javascript" src="http://myjs.fr/0.1.2/my.js"></script>
<script type="text/javascript" src="http://yass.webo.in/yass.0.3.9.min.js"></script>

<div id='test'></div>
<script>
  (function(obj) {
   var cache = {};
  
   obj.getEBI = function(id) {
    var c = cache[id];
    if (!c) cache[id] = c = document.getElementById(id);
    return c;
   };
  
  })(window);


 (function(obj) {
   var cache = {};
  
   obj.$yas= function(id) {
    var c = cache[id];
    if (!c) cache[id] = c = _(id);
    return c;
   };
  
  })(window);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$("#test");
ready
Dojo
dojo.byId("test");
ready
ExtJS
Ext.get("test");
ready
My.js
my("test");
ready
Native
document.getElementById('test');
ready
Native (cached)
getEBI("test");
ready
Yass
_("#test");
ready
Yass (cached)
$yas("#test");
ready

Revisions

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