title: How to dynamically insert a <script> tag via jQuery after page load?
body: <p>I'm having problems getting this to work.  I first tried setting my script tags as strings and then using jquery replaceWith() to add them to the document after page load:</p>
  
  <pre><code>var a = '&lt;script type="text/javascript"&gt;some script here&lt;/script&gt;';
  $('#someelement').replaceWith(a);
  </code></pre>
  
  <p>But I got string literal errors on that var.  I then tried encoding the string like:</p>
  
  <pre><code>var a = '&amp;left;script type="text/javascript"&amp;gt;some script here&amp;lt;\/script&amp;gt;';
  </code></pre>
  
  <p>but sending that to <code>replaceWith()</code> outputs just that string to the browser.</p>
  
  <p>Can someone please let me know how you would go about dynamically adding a <code>&lt;script&gt;</code> tag into the browser after page load, ideally via jQuery?</p>