How much is the negative affect on performance due to loading and using jQuery?
<p>I do a little bit of third party javascript work for a company where I am able to enter my javascript snippets into the CMS and have it run in the customer facing sites.
I have the option to switch on <code>JQuery 1.7.1</code> in the header of the site and I usually choose to do this or not depending on how much more complicated it would make my code if I didn't.</p>

<p>I have often wondered how much difference it would make if I just turned it on in all cases so even simple things like:</p>

<pre><code>document.getElementById('myElement');
</code></pre>

<p>became</p>

<pre><code>$('#myElement');
</code></pre>

<p>Where would the 'breakpoint' be in deciding it was better / more efficient / easier to switch on JQuery?</p>

<p>Today's example that made me think of this was as follows (both regular javascript followed by the JQuery equivalent ):</p>

<p><strong>Javascript:</strong></p>

<pre><code>if (document.getElementById('myElement')!== null) {
    var oldText = document.getElementById('myElement').innerHTML,
    newText = oldText.replace(/one/i,'two');
    document.getElementById('myElement').innerHTML = newText;
}
</code></pre>

<p><strong>jQuery:</strong></p>

<pre><code>if ($('#myElement').length !== 0) {
    var oldText = $('#myElement').html(),
    newText = oldText.replace('one','two');
    $('#myElement').html(newText);
}
</code></pre>

<p>And How much is the negative affect on forcing the clients to download jQuery?</p>
