title: What is the best way to check if a selector exists?
body: <p>With JQuery, to check if a selector exists, I do something like :</p>
  
  <pre><code>if ($(selector).length &gt; 0) { ... }
  </code></pre>
  
  <p>But I suppose it's maybe not the best way because I just want to know if a selector exists, not how many. Is there a way to stop the search at the first occurrence found for optimization reason ?</p>
  
  <p>Thank you!</p>
  
  <p>EDIT: To clarify : I'd like to avoid the "length" method because it checks in all the DOM. I just want to stop when one occurrence is found</p>