<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: New jQuery plugin: Object Cache</title>
	<atom:link href="http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/</link>
	<description>blog of Luciano Germán Panaro</description>
	<lastBuildDate>Fri, 11 Jun 2010 20:43:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Joey Nelson: Caching jQuery objects</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-59</link>
		<dc:creator>Joey Nelson: Caching jQuery objects</dc:creator>
		<pubDate>Fri, 11 Jun 2010 20:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-59</guid>
		<description>[...] there are more jQueryish ways of doing this but come on, you can&#8217;t beat that [...]</description>
		<content:encoded><![CDATA[<p>[...] there are more jQueryish ways of doing this but come on, you can&#8217;t beat that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luciano.panaro</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-22</link>
		<dc:creator>luciano.panaro</dc:creator>
		<pubDate>Tue, 24 Mar 2009 20:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-22</guid>
		<description>Not sure I&#039;m getting your point.

The cache returns an object reference, which is assigned to $JQ1 and $JQ2. This means that by line 3, they both point to the same object. So doing #3 and #4, would be the same as doing $(&quot;#mydiv&quot;).remove().show()

Is that what you were asking?</description>
		<content:encoded><![CDATA[<p>Not sure I&#8217;m getting your point.</p>
<p>The cache returns an object reference, which is assigned to $JQ1 and $JQ2. This means that by line 3, they both point to the same object. So doing #3 and #4, would be the same as doing $(&#8220;#mydiv&#8221;).remove().show()</p>
<p>Is that what you were asking?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBJDBJ</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-21</link>
		<dc:creator>DBJDBJ</dc:creator>
		<pubDate>Tue, 24 Mar 2009 16:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-21</guid>
		<description>What happens in this case :

1 :  $JQ1 = $$(&quot;#mydiv&quot;)
2:   $JQ2 = $$(&quot;#mydiv&quot;)
3:  $JQ1.remove() ;
4:  $JQ2.show() ; // ??????

Also , if we replace line 2: wit this :

2: $JQ2 = $JQ1

Are we going to do anything different ?</description>
		<content:encoded><![CDATA[<p>What happens in this case :</p>
<p>1 :  $JQ1 = $$(&#8220;#mydiv&#8221;)<br />
2:   $JQ2 = $$(&#8220;#mydiv&#8221;)<br />
3:  $JQ1.remove() ;<br />
4:  $JQ2.show() ; // ??????</p>
<p>Also , if we replace line 2: wit this :</p>
<p>2: $JQ2 = $JQ1</p>
<p>Are we going to do anything different ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery Object Cache Update : decodeURI</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-20</link>
		<dc:creator>jQuery Object Cache Update : decodeURI</dc:creator>
		<pubDate>Sun, 11 Jan 2009 17:14:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-20</guid>
		<description>[...] New jQuery plugin: Object Cache  [...]</description>
		<content:encoded><![CDATA[<p>[...] New jQuery plugin: Object Cache  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew luetgers</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-19</link>
		<dc:creator>andrew luetgers</dc:creator>
		<pubDate>Wed, 31 Dec 2008 17:59:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-19</guid>
		<description>All very good points Luciano, I was unaware of the defunct cacheing code removed from sizzle. I agree for the purposes you have laid my auto-caching scheme would be of no benefit, however it does not preclude you from continued use of that functionality. In the cases where I want to cache a more complex jquery chained lookup or some other object I just fall back to the .chache(&quot;someuniquename&quot;);

I my case when using the object cache I found myself facing the same annoyances i faced when I used var blah =  $(&quot;#blah&quot;). Namely i had to come up with a unique name for the item to be cached and I had to write unique code in the right place to cache an item. In my coding style I found that I was often using some derivation of the class or id as a name. So from a coding standpoint I found tha I was noy improving my code greatly over var = .... I was just using different syntax.

I defense of using a selector as a key I do like how it is more self documenting that some variable name you come up with. Secondly its easy to convert existing code with a simple find and replace because $$ will cache and retrieve, no need to know when and where to cache, you just use it. Again theres always the option to fall back to .cache(key).

With all that said jQuery allows a huge range of approaches to grabbing DOM elements which leads to different approaches to designing that interface between the DOM and the js code. Some people like one way of doing things some like another, so much of this just comes down to personal taste.

Cheers!</description>
		<content:encoded><![CDATA[<p>All very good points Luciano, I was unaware of the defunct cacheing code removed from sizzle. I agree for the purposes you have laid my auto-caching scheme would be of no benefit, however it does not preclude you from continued use of that functionality. In the cases where I want to cache a more complex jquery chained lookup or some other object I just fall back to the .chache(&#8220;someuniquename&#8221;);</p>
<p>I my case when using the object cache I found myself facing the same annoyances i faced when I used var blah =  $(&#8220;#blah&#8221;). Namely i had to come up with a unique name for the item to be cached and I had to write unique code in the right place to cache an item. In my coding style I found that I was often using some derivation of the class or id as a name. So from a coding standpoint I found tha I was noy improving my code greatly over var = &#8230;. I was just using different syntax.</p>
<p>I defense of using a selector as a key I do like how it is more self documenting that some variable name you come up with. Secondly its easy to convert existing code with a simple find and replace because $$ will cache and retrieve, no need to know when and where to cache, you just use it. Again theres always the option to fall back to .cache(key).</p>
<p>With all that said jQuery allows a huge range of approaches to grabbing DOM elements which leads to different approaches to designing that interface between the DOM and the js code. Some people like one way of doing things some like another, so much of this just comes down to personal taste.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luciano.panaro</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-18</link>
		<dc:creator>luciano.panaro</dc:creator>
		<pubDate>Wed, 31 Dec 2008 14:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-18</guid>
		<description>@andrew, sorry I didn&#039;t get back to you sooner.

A few weeks ago I was going to implement something like this, but then I realized we are thinking of different goals. This plugin&#039;s goal is caching jQuery objects to allow more manageability (instead of having to write a selector several times, just reference a key) and some faster responses (but all in all, speed was not the main goal). You would use it only for particular objects you know won&#039;t be changing regularly and you&#039;ll be referencing a lot.

On the other hand, what you want (I think) is a selector cache, and from my point of view that should be done at the selector&#039;s engine level. Otherwise, it&#039;d be useless for stuff like $(&quot;.class_something&quot;).children(&quot;.selected&quot;). Also having to manually refresh cached items doesn&#039;t look too good (what will happen when you have 10+ cached items?).

I know Sizzle had a caching system but it&#039;s been removed recently (explanation here: http://groups.google.com/group/jquery-dev/browse_thread/thread/bf2a17146c5c1ca5). However, I guess that doesn&#039;t mean it can&#039;t be done.

Anyway, I would like to know your (and everybody&#039;s) thoughts on this. I believe this plugin shouldn&#039;t do much, or try to be too clever. I just wanted a way to avoid doing &quot;var obj = $(...)&quot; and I think the plugin the way it is right now does exactly that.</description>
		<content:encoded><![CDATA[<p>@andrew, sorry I didn&#8217;t get back to you sooner.</p>
<p>A few weeks ago I was going to implement something like this, but then I realized we are thinking of different goals. This plugin&#8217;s goal is caching jQuery objects to allow more manageability (instead of having to write a selector several times, just reference a key) and some faster responses (but all in all, speed was not the main goal). You would use it only for particular objects you know won&#8217;t be changing regularly and you&#8217;ll be referencing a lot.</p>
<p>On the other hand, what you want (I think) is a selector cache, and from my point of view that should be done at the selector&#8217;s engine level. Otherwise, it&#8217;d be useless for stuff like $(&#8220;.class_something&#8221;).children(&#8220;.selected&#8221;). Also having to manually refresh cached items doesn&#8217;t look too good (what will happen when you have 10+ cached items?).</p>
<p>I know Sizzle had a caching system but it&#8217;s been removed recently (explanation here: <a href="http://groups.google.com/group/jquery-dev/browse_thread/thread/bf2a17146c5c1ca5)" rel="nofollow">http://groups.google.com/group/jquery-dev/browse_thread/thread/bf2a17146c5c1ca5)</a>. However, I guess that doesn&#8217;t mean it can&#8217;t be done.</p>
<p>Anyway, I would like to know your (and everybody&#8217;s) thoughts on this. I believe this plugin shouldn&#8217;t do much, or try to be too clever. I just wanted a way to avoid doing &#8220;var obj = $(&#8230;)&#8221; and I think the plugin the way it is right now does exactly that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew luetgers</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-17</link>
		<dc:creator>andrew luetgers</dc:creator>
		<pubDate>Wed, 31 Dec 2008 01:05:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-17</guid>
		<description>what do you think of this it may be a tiny bit faster theres less type checking, it auto caches your lookups uisng the selector as the key and points back to a regular jquery object if the argument is not a string, also added a refresh method &lt;code&gt;; if(window.jQuery) {
	_$$ = window.$$; //in case overwrite
	window.jQueryCache = window.$$ = window.$c = function($) {
		// Add object_cache dictionary to jQuery
		$.extend({
			object_cache: {}
		});

		$.fn.extend({
			cache: function (selector) {
				return $.object_cache[selector] = this;
			}
		});

		// $$() function and methods
		var jQueryCache = function(selector) {
			if (typeof selector == &quot;string&quot;) {
				return $.object_cache[selector] &#124;&#124; $(selector).cache(selector);
			} else {
				return $(selector);
			}
		};

		jQueryCache.refresh = function(selector) {
			return $(selector).cache(selector);
		};

		jQueryCache.remove = function(selector) {
			$.object_cache[selector] = null;
		};

		jQueryCache.clear = function() {
			$.object_cache = [];
		};

		jQueryCache.noConflict = function() {
			window.$$ = _$$;
			return jQueryCache;
		}

		return jQueryCache;
	}(jQuery);
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>what do you think of this it may be a tiny bit faster theres less type checking, it auto caches your lookups uisng the selector as the key and points back to a regular jquery object if the argument is not a string, also added a refresh method <code>; if(window.jQuery) {<br />
	_$$ = window.$$; //in case overwrite<br />
	window.jQueryCache = window.$$ = window.$c = function($) {<br />
		// Add object_cache dictionary to jQuery<br />
		$.extend({<br />
			object_cache: {}<br />
		});</p>
<p>		$.fn.extend({<br />
			cache: function (selector) {<br />
				return $.object_cache[selector] = this;<br />
			}<br />
		});</p>
<p>		// $$() function and methods<br />
		var jQueryCache = function(selector) {<br />
			if (typeof selector == "string") {<br />
				return $.object_cache[selector] || $(selector).cache(selector);<br />
			} else {<br />
				return $(selector);<br />
			}<br />
		};</p>
<p>		jQueryCache.refresh = function(selector) {<br />
			return $(selector).cache(selector);<br />
		};</p>
<p>		jQueryCache.remove = function(selector) {<br />
			$.object_cache[selector] = null;<br />
		};</p>
<p>		jQueryCache.clear = function() {<br />
			$.object_cache = [];<br />
		};</p>
<p>		jQueryCache.noConflict = function() {<br />
			window.$$ = _$$;<br />
			return jQueryCache;<br />
		}</p>
<p>		return jQueryCache;<br />
	}(jQuery);<br />
}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luciano.panaro</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-16</link>
		<dc:creator>luciano.panaro</dc:creator>
		<pubDate>Sun, 14 Dec 2008 22:24:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-16</guid>
		<description>@andrew, that is actually a good idea. I first thought of making the plugin work that way but I decided to change it to the current one. So I will probably be adding this during this week :). thanks for your feedback!</description>
		<content:encoded><![CDATA[<p>@andrew, that is actually a good idea. I first thought of making the plugin work that way but I decided to change it to the current one. So I will probably be adding this during this week <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . thanks for your feedback!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew luetgers</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-15</link>
		<dc:creator>andrew luetgers</dc:creator>
		<pubDate>Sun, 14 Dec 2008 21:53:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-15</guid>
		<description>you should implement auto caching by stringifying selectors into valid keys so that you can input any valic slelector into $$ and it will always rerieve fresh dom or cached if its there, and allow a boolian for forcing an refresh lookup for those times when you need to update the dom and thus the cached lookup.</description>
		<content:encoded><![CDATA[<p>you should implement auto caching by stringifying selectors into valid keys so that you can input any valic slelector into $$ and it will always rerieve fresh dom or cached if its there, and allow a boolian for forcing an refresh lookup for those times when you need to update the dom and thus the cached lookup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin Sterling</title>
		<link>http://decodeuri.com/2008/11/20/new-jquery-plugin-object-cache/#comment-14</link>
		<dc:creator>Benjamin Sterling</dc:creator>
		<pubDate>Thu, 20 Nov 2008 18:59:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.decodeuri.com/?p=67#comment-14</guid>
		<description>That is actually a very great idea, I like this a lot.</description>
		<content:encoded><![CDATA[<p>That is actually a very great idea, I like this a lot.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
