dojo attach points vs selecting dom nodes (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/_Widget.xd.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/_Templated.xd.js"></script>
<script>
  dojo.ready(function() {
   var tmpl = '<div class="outer"><div class="inner" dojoAttachPoint="inner">inner</div></div>',
       my = {},
       sel = '.inner';
  
   dojo.declare("my.ThingerA", [dijit._Widget, dijit._Templated], {
    templateString: tmpl,
    postCreate: function() {
     dojo.query(sel, this.domNode);
    }
   });
  
   dojo.declare("my.ThingerB", [dijit._Widget, dijit._Templated], {
    templateString: tmpl
   });
  
   dojo.declare("my.ThingerC", [dijit._Widget, dijit._Templated], {
    templateString: tmpl,
    postCreate: function() {
     this.domNode.querySelectorAll(sel);
    }
   });
  });
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
selectors
new my.ThingerA();
ready
attachpoints
new my.ThingerB();
ready
qsa only
new my.ThingerC();
ready

Revisions

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