document.createElement(“script”) synchronously
You can create your <script> element with an “onload” handler, and that will be called when the script has been loaded and evaluated by the browser. var script = document.createElement(‘script’); script.onload = function() { alert(“Script loaded and ready”); }; script.src = “http://whatever.com/the/script.js”; document.getElementsByTagName(‘head’)[0].appendChild(script); You can’t do it synchronously. edit — it’s been pointed out that, … Read more