I am trying to load a javascript file that's stored in an external server.I tried using plain js to do so in the following manner:
$(document).ready(function(){ scriptObject = document.createElement('script'); scriptObject.type = 'text/javascript'; scriptObject.async = true; scriptObject.src="https://seal.verisign.com/getseal?host_name=esewa.com.np&size=S&use_flash=YES&use_transparent=YES&lang=en", }); $(window).load(function(){ document.getElementByTagName('head')[0].appendChild(scriptObject); }); Since Js is single threaded and the file loading procEss took a lot of time i tried using ajax and js to do so in the following manner
$(document).ready(function(){ scriptObject = document.createElement('script'); scriptObject.type = 'text/javascript'; scriptObject.async = true; $.ajax({ type: "GET", url:"https://seal.verisign.com/getseal?host_name=esewa.com.np&size=S&use_flash=YES&use_transparent=YES&lang=en", dataType: "script", success: function(data) { scriptObject.src= data ; $(window).load(function(){ document.getElementByTagName('head')[0].appendChild(scriptObject); }); } }); }); However I am not sure if one can load .js file in the way that i have done with ajax and jquery. Is there a better way for doing this? Any help would be appreciated.