You can include a javascript like this:
function include(filename) Â {
var head = document.getElementsByTagName('head')[0]; script = document.createElement('script'); script.src = filename; script.type = 'text/javascript'; head.appendChild(script)
}
Read more here: http://forums.digitalpoint.com/showthread.php?t=146094
Or even better:
You can easily read another JS-file inside the javascript using jquery:
$.getScript("my_lovely_script.js", function(){ Â Â alert("Script loaded and executed."); Â Â Â // here you can use anything you defined in the loaded script });
Read here: http://stackoverflow.com/questions/950087/include-javascript-file-inside-javascript-file