What is the most efficient way to access DOM elements in jQuery?
<p>I am writing a jQuery plugin and I am at the optimization stage.</p>

<p>I wonder which of these leads to a quicker script in general, and what sort of mitigating factors are important:</p>

<ol>
<li>Have the script generate lots of classes and ids at the start so finding elements in the dom is easier (quicker too?) later on.</li>
<li>Keep classes and ids to a minimum (so save time by not creating them), but then look for elements in more convoluted ways later (eg the nth item in an object), which I presume is slower than getting by id/class.</li>
</ol>
