I load external scripts to my site with this code:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://example.com/script.js';
document.getElementsByTagName("head")[0].appendChild(script);
It works, but how to check, if it was an error at the loading? For example timeout, or a server error.