I want to start manipulating a DOM element as soon as it’s available, to minimize the time that it might appear in its original state on screen. I know in YUI you’d use YAHOO.util.Event.onContentReady and I’m pretty sure you’d use bind in jQuery. I’m new Dojo, and I’m not sure: What’s the “Dojo Way” to do this?
UPDATE: I specifically don’t want to wait for the whole page (which is ridiculously data-heavy; the markup alone is potentially a MB or more) to load. I want to immediately start looking for the element in the DOM and start processing as soon as it’s there, without waiting for ALL the markup to download, be parsed, and inserted into the DOM—that could take a relatively long time. I want to start looking at the DOM and get to work as soon as this tiny fragment is there. Given that constraint, isn’t dojo.ready a poor fit? My understanding is that it waits for the entire DOM to be ready, similar to onDOMReady.
The most precise way of injecting functionality after a piece of DOM is added to the tree is to have the <script> that requires it placed directly below it in markup. It seems less sexy than something like onContentReady, but onContentReady is just a polling mechanism that may end up executing your callback around the same time as domready, anyway, long after the relevant DOM subtree is ready for scripting.
Browsers can assemble a DOM tree pretty fast. And with a polling solution such as onContentReady, you’re slowing down the page assembly/render by having to execute the code that searches for the targeted element(s) every few milliseconds.
I’d stick with keeping your <script>s at the bottom of the <body> or if you must, putting the must-run-now-damnit code in a <script> after the required markup.
I am not familiar with dojo’s API, so I can’t answer your specific question wrt dojo if the above is not helpful.
(edited to escape the leading < in tags so they would display)