Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js appendchild wait for callback

function injectScript(src,callback){
	var script = document.createElement('script');
        script.src = src;
        script.onload=function(){
            callback();
        }
        document.head.appendChild(script);
}
injectScript('https://www.mysite.com/somescript.js', function(){
	//the script is now all loaded
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: window.location.href target blank 
Javascript :: threejs cube mesh 
Javascript :: image next src url 
Javascript :: push tr in tbody using jquery 
Javascript :: d3.js clear svg 
Javascript :: passport.initialize() middleware not in use 
Javascript :: read only javascript 
Javascript :: input in node js 
Javascript :: regx get only domain name from url 
Javascript :: mongodb delete user 
Javascript :: int to string js 
Javascript :: get height component react 
Javascript :: open google map with latitude and longitude javascript 
Javascript :: javacript open url in new tab 
Javascript :: python dictionary to json 
Javascript :: how to view local storage in chrome 
Javascript :: sanitise string js 
Javascript :: array reverse without mutating 
Javascript :: componentdidmount hooks 
Javascript :: express js limit access based on rate 
Javascript :: python json to excel converter 
Javascript :: remove negative sign from number javascript 
Javascript :: how to make something spawn on a random x axis p5.js 
Javascript :: reverse number javascript 
Javascript :: laravel jquery ajax post csrf 
Javascript :: count 1 to 5 javascript 
Javascript :: usehistory not found in react-router-dom 
Javascript :: ckeditor change value 
Javascript :: js get url params 
Javascript :: javascript reverse array map 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =