I think that in order to actually execute the script loaded from outside, you need to do an eval () of the content. You do not add it to the DOM, since it is a script, you add it to the JS runtime. There may be other ways to do this, but eval () is usually considered a security hole, as malicious code can be evaluated.
What I usually do is generate sections of templates on the server, so I know that all my JS exist when the DOM is ready.
Flavorcape
source share