title: What's the better practice: eval or append script?
body: <p>I need to execute a custom piece of JavaScript I got from some AJAX call. I could do an <code>eval</code> of the string or I could just append it in a <code>script</code>-tag to the DOM. Which method would be better?</p>
  
  <pre><code>var dynamicScript = 'alert(\'Hello world!\');';
  </code></pre>
  
  <p>Method 1 - <strong>Script</strong>:</p>
  
  <pre><code>var x = '&lt;script type="text/javascript"&gt;' + dynamicScript  +'&lt;/scr' + 'ipt&gt;';
  $(document.body).append(x);
  </code></pre>
  
  <p>Method 2 - <strong>Eval</strong>:</p>
  
  <pre><code>eval(dynamicScript);
  </code></pre>
  
  <p>What method is better and why? Or is there  an ever better alternative?</p>