Just discovered this technique. Is this old hat? Would there be any
disadvantage to doing this?
In your external .js file:
/*
Summary: includes external scripts in this external script
so that you don't have to reference them within the (x)html
document
files.
Remarks:
In effect this inserts something like
<script type="text/javascript"
src="referencingExternalLibrariesB.js"></script>
into the html document.
Param:
scriptUrl (String)
an absolute or relative url.
Usage: In your external scripts, at the top of your documents,
include("file:///C:/temp/myScript.js");
include("otherScript");
*/
function include(scriptSrc) {
var headElement = document.getElementsByTagName("head")[0];
var scriptElement = document.createElement("script");
scriptElement.setAttribute("type", "text/javascript");
scriptElement.setAttribute("src", scriptSrc);
headElement.appendChild(scriptElement);
}
Full example online:
<
http://www.softmake.com.au/webScript...alLibraries.ht
ml>