JQUERY - Speeding Up Code
<p>I have a generic question.
I've heard many times that a great way to speed up your code is to not call the same selector over and over again - eg - 4 times one DIV selector:</p>

<pre><code>    if($('div#spotJoinSite').is(':visible')) {
        var pos = $('div#spotJoinSite').offset();  
        var width = $('div#spotJoinSite').width();
        var height = $('div#spotJoinSite').height();
        $('div#container_join_messages').css({'position': 'fixed'});        
    }
</code></pre>

<p>Would it therefore be a good idea to have a section at the top of a js script that connected all the required selectors to variables - eg:</p>

<pre><code>        var spotJoinSite = $('div#spotJoinSite');
        var container_join_messages = $('div#container_join_messages');
</code></pre>

<p>The the variables could be exclusively used.</p>

<p>Is this a good idea or a bad idea?
What speed increases could be expected? noticable or not?
What are the potential problems?
Would you do it?</p>

<p>If the variable names are same as the selector it would be easy to reference them.</p>
