I think this code is broken. Have you tested it? What's your method to test these changes? Did you get any console errors?

This is where I think you copied it from
https://gist.github.com/neilsoult/7255583

This is where they talk about attachEvent and addEventListener taking callbacks.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener
http://stackoverflow.com/questions/2657182/correct-usage-of-addeventlistener-attachevent

To make this work you'd need to make loadScript() return a callback.