Reference remote javascript within javascript -


this question has answer here:

let's have block of javascript code, , want take of , host somewhere else.

is possible load now-remote part of code in places before, executable code, within original block, whole thing functions did before?

if so, how referenced within javascript?

if code function or module of sort wich can call after loaded, can load page , call new ,oaded function. can use:

function depend( url , callback ) {   var script = document.createelement( 'script' );   var scripts = document.getelementsbytagname( 'script' )[0];   script.async = true;   script.onload = function()   {     script.onload = null;     callback();   }   script.src = url;   ( document.getelementsbytagname( "head" )[ 0 ] ).appendchild( script ); } 

and use like:

depend('path script', function( ) {   // call function herer.... }); 

Comments

Popular posts from this blog

vue.js - Create hooks for automated testing -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

serial port - hub4com OVERRUN Error -