> you can do that trough ajax, using a wait function to load the
> scripts in order, but going other way with this.

I could read the files in proper order with XMLHttpRequest(), then
merge them into one variable and finally print them between
<script></script> tags. Is that what you meant?

var mergedScripts = "";

function readScript(path) {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", path, false);
  xhr.send();
  mergedScripts += xhr.responseText;
}

readScript("script-1.js");
readScript("script-2.js");
readScript("script-3.js");

var scriptTag = document.querySelector("script#merged-scripts");
scriptTag.innerHTML = mergedScripts;

This looks awful :/

I forgot to mention it, but it's important for me that the JS files
are linked from HTML page, not directly injected into it. So basically
I just want to output those three lines of code in proper order:

<script src="script-1.js" charset="UTF-8">
<script src="script-2.js" charset="UTF-8">
<script src="script-3.js" charset="UTF-8">

What's wrong with my original loadScript() function? I was scratching
my head for several hours but I still don't get it why it doesn't work
correctly on Safari.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to