As mentioned in my comment above, you can't do quite what you want since JavaScript itself has no mechanism for including other JavaScript files. JavaScript files are included in the document using the HTML script element.
However, we could write one script ("active.js") that we include in the document and this manually creates an additional script element for each external JavaScript file. It should be noted, however, that this could suffer a degradation in performance since we are creating additional HTTP requests.
I think you will also need to separate your current inline script into an external file in order to avoid a "chicken vs egg" scenario where you are referring to elements of "tyr1.js" before it has loaded.
So your "active.js" script becomes something like:
/**
* Combined JavaScript files (active.js)
* - Creates script elements for any additional JS files
*/
(function() {
var head = document.getElementsByTagName('head')[0];
// Scripts to include
var js = [
'http://domain.com/tyr1.js',
'/inline.js' /* Change path to where this is located */
];
// Clone for every external script that needs to be included
var jsElem = document.createElement('script');
jsElem.type = 'text/javascript';
// Step through scripts to include
for (var i=0; i<js.length; i++) {
var newJsElem = jsElem.cloneNode(false);
newJsElem.src = js[i];
// Append to HEAD section
head.appendChild(newJsElem);
}
})()
This of course assumes your scripts are to be placed in the HEAD section of the document.
scriptelement. Having said that, your activate.js could potentially create thescriptelements in the DOM, requesting the appropriate files.