No, it does not cache. Each time you make a page query, a new call is made.
For better performance, always cache commonly used selectors:

$myID = $('#myID'); // $ used for initial var to indicate a jQuery object
var text = $myID.text();
var color = $myID.css('color');

Also, you should always use the raw ID reference where possible as it's far
more performant than tacking on a tag name first:

$myID = $('#myID'); // this performs better than the line below
$myID = $('div#myID'); // avoid this where possible, performance will
degrade



andy


-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of jonathan
Sent: Wednesday, May 27, 2009 12:44 AM
To: jQuery (English)
Subject: [jQuery] does selectors $ cache?


does selectors cache? for example, if I do $('#myid') twice, does it search
through the document twice for myid?


Reply via email to