I have seen Scriptaculous.js file to include its required javascript files dynamically. Is there any better approach to include javascript dynamically.
For example,
there are many different ways, but the way Google loads additional scripts is like this:
function getScript(src) {
document.write('<' + 'script src="' + src + '"' +
' type="text/javascript"><' + '/script>');
}
This is taken directly from Google maps loader.
Writing a script tag directly to the document is the simplest and most efficient way.