So, there's this thing called [require.js](http://requirejs.org/), which I think you might want to look into.  It's made by James Burke, who works for us.  :)  He's jrburke on irc, and you should feel free to ping him (or me) if you can't get it working.  ;)