Loading Javascript file by using document.write() -- The orginal article is Javascript Async Loading
The Javascript file is alert.js
The test code as below:
<script language="javascript" type="text/javascript"> function loadjs(script_filename) { document.write('<' + 'script language="javascript" type="text/javascript"'); document.write(' src="' + script_filename + '">'); document.write('<'+'/script'+'>'); alert("loadjs() exit..."); } var script = './alert.js'; loadjs(script); alert("loadjs() finished!"); </script> <script language="javascript" type="text/javascript"> alert("another block"); </script>