Opened 13 years ago

Closed 13 years ago

#9574 closed enhancement (wontfix)

Add more jQuery idioms

Reported by: Les Owned by: anonymous
Priority: low Milestone: tbd
Component: General Version: 1.3.1
Keywords: Cc:
Blocked By: Blocking:


I like the jQuery idioms. They are brief, intuitive and IMO improve programmer productivity.

I suggest adding these three enhancements, see examples:

// current
dojo.addOnLoad(function(){ });
// new
dojo(function(){ });
// current
var div = dojo.create(“div”);
// new
var div = dojo(“div”);
// current
var divs = dojo.query("div.myClassName");
// new
var divs = dojo(“div.myClassName");

Change History (3)

comment:1 Changed 13 years ago by dante

Priority: highlow

we've discussed this before, voting it down as overloading dojo as a function as well as a namespace complicates things significantly.

your two examples with create/query conflict too.


would presumably query for all div tags rather than create one. it would have to be


I'm -1 on the listed proposed changes above. Seems plugd would be a better home for them. Have you seen that project?

with conflict mode on, the above examples would be:

dojo.load(function(){ /* dom ready */ });
// or
$(document).ready(function(){ })


$("<div></div>"); // creates
$("div.myClassName"); // finds

we are also working on a full jq-compat layer which will fill in any other gaps should you choose to load it. This is a work in progress and not yet ready for consumption (though targeting 1.4)

comment:2 Changed 13 years ago by Les

Thank you for the plugd and jq-compat layer info.

In the 2nd example I indeed intended:


Dojo is very powerful. BUT it bothers me that the code is verbose. See for example the test files for TaskSpeed?. The Dojo test file is longer compared to both jQuery and MooTools?.

comment:3 Changed 13 years ago by dante

Resolution: wontfix
Status: newclosed

neither of these things can be in 1.x timeframe anyway. plugd offers these idioms at minimal cost, and following a "plugin pattern" of:

(function(d, $){ 
  // user code

provides the shorthandedness desired most of the time.

I am leaning more and more towards putting plugd in an ext-dojo dojox project:

dojox/ext-dojo/base.js -> provides plugd.base code, ext-dojo/trigger.js provides experimental trigger (basically everything in plugd, but also opening the proverbial floodgates to additional plugins like this)

Note: See TracTickets for help on using tickets.