I am appending an external script to a div with Jquery/JS. I cannot include the external script in the head. I need to append it to a div which is being created with Jquery. The external script loads asynchronously, uses document.write and I have no control over that script. 

What I want ultimately is to load the external script and append it to the div dynamically. I'm creating this div on the fly with JavaScript. So this has to be done only in js, not in html. If I place the external script in html statically it would work, but will not render content inside the div container. However when I place it dynamically it won't work.

Here's what I tried. But I cannot see the script nor the object getting appended inside div. I need to put in the script inside div so that it renders content inside it. 

```
// this is the external code
// the externalscript.js takes in the value of externalprop1 & renders an iframe inside "div2" so externalobject has to be defined before the externalscript.js is called.  
var externalobject = {
    externalprop1 = "prop1"
};

var newscript      = document.createElement("script")
    newscript.type = "text/javascript"
    newscript.src  = "externalscript.js"

// end of external code

dynamic_content =  '<li>';
dynamic_content += '<div class=" div1">';
dynamic_content += '<div class="div2" id= "div2here"></div>';
dynamic_content += '</div>';
dynamic_content += '</li>';

```

I have appended dynamic\_content to the body & then I am doing:

```
$('#div2here').append(newscript);

```