Reference remote javascript within javascript -
this question has answer here:
- how use external “.js” files 5 answers
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
Post a Comment