Hold while JS loads

Hello,
I am calling a JS file within another JS file with document.write("<script type=‘text/javascript’ src=’…’></script>");

after that some functions are written over there again with document.write. The problem is The script executes all the codes without waiting for inner JS loading. Is there any way to hold before the inner JS is fully loaded?