I'm trying to build some small widgets tools that webmasters can embed in their websites.

Is there any way that the webmaster can simply load this tool by including a script like this?

```
<script src="http://mysite/widget.js"></script>

```

I tried to inject it by loading it in AJAX and then do an `appendChild()` on the body, it's working this way but the JS is not executed.

Content to be injected:

```
<div>one div</div>
<script>alert('some js')</script>

```

widget.js

```
function load(content) {
  var $body = document.body,
      $div = document.createElement("div");
  $div.id = "widget";
  $div.innerHTML = content; 
  $body.appendChild($div);
}

```

The content variable contains HTML and JS but the JS is not executed when injected.