title: How to append a raw JavaScript tag to document.body without jQuery
body: <p>I get a raw JavaScript tag from the server:</p>
  
  <pre><code>"&lt;script&gt;alert('hi');&lt;/script&gt;"
  </code></pre>
  
  <p>Now, I need to append it to <code>&lt;body&gt;</code> so that it fires.  I can't simply create a new script element, because this string already contains the <code>&lt;script&gt;</code> part.  Is there something analogous to</p>
  
  <pre><code>child = document.createElementFromHTML("&lt;script&gt;alert('hi');&lt;/script&gt;");
  document.body.appendChild(child)
  </code></pre>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT</p>
  
  <p>Here's why it's not a duplicate, hall monitors:</p>
  
  <p>If you set the inner html of a div to be a script it won't fire.  I need to append an element generated from only text to the body.</p>
  
  <p>EDIT 2 </p>
  
  <p>final solution:</p>
  
  <pre><code>window.onload = function() {
  document.body.innerHTML += "&lt;script&gt;alert('hi');&lt;/script&gt;";
  var script = document.scripts[document.scripts.length - 1];
  var s = document.createElement("script");
  s.textContent = script.textContent;
  document.body.removeChild(script);
  document.body.appendChild(s);
  }
  </code></pre>