This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
Splitting the configuration
akloeckner edited this page Nov 12, 2019
·
1 revision
The CONFIG
variable can become somewhat unyieldy pretty soon. If you encounter this, it might be a good idea to split up your config.js
for better readability. If you decide to do so, you can use the following function to load any JavaScript file at any place in your config.js
:
function loadJS(url) {
var xhttp = new XMLHttpRequest();
var script = document.createElement( "script" );
xhttp.open("GET", url+suffix, false);
xhttp.send();
script.text = xhttp.responseText;
document.head.appendChild( script ).parentNode.removeChild( script );
}
It can be used like this:
loadJS('templates.js'); //defines var TEMPLATES
alert(TEMPLATES);