I want to include a local .js file in my index.html page, based on the outcome of an 'if' statement, as described in my sample code below. I need the .js contents to be included in the initial loading of the page, as the contents will be displayed in the html itself on load.
index.html:
<html>
<head>
<script src="script.js"></script>
</head>
<body>
<script>
include_another_script();
</script>
</body>
</html>
script.js:
include_another_script function(){
var url;
if( //some stuff){
url = "script1.js";
} else {
url = "script2.js";
}
document.write("<script src=url></script>");
}