/** * function to load external js through javascript. * * @param url - javascript url * @param location - location of the dom (e.g. document.head) */ var loadExternalJS = function(url, location, callback){ var scriptTag = document.createElement('script'); scriptTag.src = url; scriptTag.type = 'text/javascript'; /* Then bind the event to the callback function. There are several events for cross browser compatibility. */ scriptTag.onreadystatechange = callback; scriptTag.onload = callback; window.atlGlobalLoadStart = new Date(); /* Fire the loading */ location.appendChild(scriptTag); };