This afternoon I revisited some old code I wrote to address the problem where sometimes you want to do the following:

1
2
insertSomethingIntoDOM();
accessOrSetSomethingInDOMContentJustInserted();

Even though that’s perfectly acceptable within JS, it takes time for the browser rendering engine to do the job of actually inserting the DOM, so it may not be ready for the second line to actually find the content it just inserted. I outlined the whole problem in an old post here.

Anyway, I updated the code in that post and rewrote it into a requireJS module. You can find it here:
https://gist.github.com/4242808. It’ll be included in the upcoming Data Generator rewrite.