Including JavaScript into JavaScript (using Dojo)
Ever thought of including a JavaScript class into another one? Usually you place all required JavaScript modules in the right order within the head of the page where you want to use them. Sometimes I prefer loading the requirements within the script (with checking if it has already been loaded before) instead of writing a lot of documentation.
The following code snippet uses Dojo 1.3+ API to create a script tag and place it to the head as the first child:
var script_url = 'http://www.topfstedt.de/js/foo.js';
var script_obj = dojo.create('script', {
'src': script_url, 'type':'text/javascript'
});
dojo.query("head").addContent(script_obj, "first");