Hello.
I have a script (S1) that depends on other script (S0) so I have to
include both scripts in all pages:
<script type="text/javascript" src="/js/S0.js"></scrip>
<script type="text/javascript" src="/js/S1.js"></scrip>
I have read that is is posible to load one script from any other:
function loadScript (scriptUrl) {
var head = document.getElementById("head");
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
head.appendChild(script);
}
Supose that I want to load S1 from S0:
S0.js:
../..
loadScript('S1.js');
s1Function(); // A function defined inside S0
index.shtml:
<head>
<script src="S0.js">
</head>
The code above doesn't work because S1.js it is loaded after the end of
S0.js and not when I load S1.js with loadScript.
¿It is posible to load S1.js right after invoke loadScript('S1.js') so I
could use S1 functions' in S0.js?
Thanks.