Creating dom elements with jquery - performance difference?
<p>I really dont like writing something like</p>

<pre><code>$('body').append('&lt;div class="foo"&gt;foo&lt;/div&gt;');
</code></pre>

<p>Because i usually end up with a quite messy string.</p>

<p>I prefer doing something like</p>

<pre><code>var $div = $('&lt;div/&gt;').attr({ 'class' : 'foo' }).text('foo');
$('body').append($div);
</code></pre>

<p>Someone told me that the last option is a lot slower, performance-wise. So i would like some input from you guys. Is there a difference? Which way do you prefer?</p>

<p>Thanks</p>
