Is there any reason to do a solution using a dynamically created <script> tag instead of eval()?
<p>There's some good reasons to avoid the eval() function in JavaScript, namely security risks when including user input in the eval() code. However, in a situation where the eval() code does not include anything affected by user input (in my particular situation, we have dynamic templates defined in XML files - these templates can also specify complex validation functions, javascript code that is embedded in the XML, which is then received by the client via AJAX), is there any reason to avoid the eval() function?</p>

<p>I came up (I'm probably not the first, but I haven't seen this done) with a solution using a dynamically created inline  tag instead of eval():</p>

<pre><code>$(scriptObject).text(strJSCode);
</code></pre>

<p>A simple example can be seen at <strong><a href="http://jsfiddle.net/H7EG9/1/" rel="nofollow">http://jsfiddle.net/H7EG9/1/</a></strong> (I know this example <strong>does</strong> use user input, but that's just to make it easy to demonstrate).</p>

<p>Is there any reason to do this instead of eval()? The outcome is basically the same, although this option might appear less "scary" to the die-hard foes of eval().</p>
