<?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/"
		>
<channel>
	<title>Comments on: 76 bytes for faster jQuery</title>
	<atom:link href="http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:03:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Drew Wells</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-30273</link>
		<dc:creator>Drew Wells</dc:creator>
		<pubDate>Fri, 22 Oct 2010 16:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-30273</guid>
		<description>This may help better understand how your shortcut works.  The following code doesn&#039;t work with jQuery.single:
&lt;code&gt;
_$().each([1,2,3],function(){});
//TypeError: Object 1,2,3 has no method &#039;apply&#039;
$().each([1,2,3],function(){});
//Empty object returned w/jQuery set to prototype
&lt;/code&gt;

This also gives different results:
&lt;code&gt;
_$([1,2,3]).each(function(n,i){ console.log(n,i); });
&gt; 0 [1,2,3]
&gt; Object returned first element is an array
$([1,2,3]).each(function(n,i){ console.log(n,i); });
&gt; 0 1
&gt; 1 2
&gt; 2 3
&gt; Array returned, extending jQuery
&gt; Object
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>This may help better understand how your shortcut works.  The following code doesn&#8217;t work with jQuery.single:<br />
<code><br />
_$().each([1,2,3],function(){});<br />
//TypeError: Object 1,2,3 has no method 'apply'<br />
$().each([1,2,3],function(){});<br />
//Empty object returned w/jQuery set to prototype<br />
</code></p>
<p>This also gives different results:<br />
<code><br />
_$([1,2,3]).each(function(n,i){ console.log(n,i); });<br />
&gt; 0 [1,2,3]<br />
&gt; Object returned first element is an array<br />
$([1,2,3]).each(function(n,i){ console.log(n,i); });<br />
&gt; 0 1<br />
&gt; 1 2<br />
&gt; 2 3<br />
&gt; Array returned, extending jQuery<br />
&gt; Object<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexsandro</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-29761</link>
		<dc:creator>Alexsandro</dc:creator>
		<pubDate>Sat, 28 Aug 2010 19:50:04 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-29761</guid>
		<description>jQuery should care of cache carefully not completely, cos illegal usage I think probably cause slower or big list of cache items same using search list like binary list and whatever.</description>
		<content:encoded><![CDATA[<p>jQuery should care of cache carefully not completely, cos illegal usage I think probably cause slower or big list of cache items same using search list like binary list and whatever.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dust</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-29228</link>
		<dc:creator>dust</dc:creator>
		<pubDate>Thu, 20 May 2010 10:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-29228</guid>
		<description>wow~~ learn more thing,mark</description>
		<content:encoded><![CDATA[<p>wow~~ learn more thing,mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28791</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Apr 2010 21:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28791</guid>
		<description>@Graham, that&#039;s a good idea -- so, essentially, instead of having to call &lt;code&gt;jQuery.single&lt;/code&gt;, the wrapped object could be passed to the &lt;code&gt;each&lt;/code&gt; callback? I think I&#039;m gonna bring this up on the jQ forums when I get a chance. :)

@Marek, I had never heard of the &quot;Flyweight pattern&quot;, so thanks for bringing it up! 

&lt;blockquote&gt;&lt;p&gt;to remember all quirks and cross-browser issues is pointless to me&lt;/p&gt;&lt;/blockquote&gt;

Well, obviously, knowing &lt;em&gt;all&lt;/em&gt; quirks is out of the question, but I think at least a rudimentary understanding of potential points of unreliability is very important.</description>
		<content:encoded><![CDATA[<p>@Graham, that&#8217;s a good idea &#8212; so, essentially, instead of having to call <code>jQuery.single</code>, the wrapped object could be passed to the <code>each</code> callback? I think I&#8217;m gonna bring this up on the jQ forums when I get a chance. <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>@Marek, I had never heard of the &#8220;Flyweight pattern&#8221;, so thanks for bringing it up! </p>
<blockquote><p>to remember all quirks and cross-browser issues is pointless to me</p>
</blockquote>
<p>Well, obviously, knowing <em>all</em> quirks is out of the question, but I think at least a rudimentary understanding of potential points of unreliability is very important.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marek Stasikowski</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28656</link>
		<dc:creator>Marek Stasikowski</dc:creator>
		<pubDate>Tue, 20 Apr 2010 22:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28656</guid>
		<description>Isn&#039;t this http://en.wikipedia.org/wiki/Flyweight_pattern?
Would be cool to see jQuery be meeting more of actual computer science.
Oh, and as to DOM scripting - I don&#039;t agree. It&#039;s good to be aware that there is a href and id and whatever property on a DOM element, yet to remember all quirks and cross-browser issues is pointless to me. If I end up with a low performance application, I&#039;ll profile it and remove those extra jQuery instances as needed. Perfection kills, worrying about optimization too much and too early is the root of all evil, etc. On the other hand, if a library has this shared flyweight object implemented, it automatically encourages it&#039;s use (like in Ext JS).

PS.
Since I hear more and more of you people yelling to know the DOM API by heart, I&#039;m actually printing out a cheat sheet and maybe consider using it from time to time. Maybe. :)</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t this <a href="http://en.wikipedia.org/wiki/Flyweight_pattern?">http://en.wikipedia.org/wiki/Flyweight_pattern?</a><br />
Would be cool to see jQuery be meeting more of actual computer science.<br />
Oh, and as to DOM scripting &#8211; I don&#8217;t agree. It&#8217;s good to be aware that there is a href and id and whatever property on a DOM element, yet to remember all quirks and cross-browser issues is pointless to me. If I end up with a low performance application, I&#8217;ll profile it and remove those extra jQuery instances as needed. Perfection kills, worrying about optimization too much and too early is the root of all evil, etc. On the other hand, if a library has this shared flyweight object implemented, it automatically encourages it&#8217;s use (like in Ext JS).</p>
<p>PS.<br />
Since I hear more and more of you people yelling to know the DOM API by heart, I&#8217;m actually printing out a cheat sheet and maybe consider using it from time to time. Maybe. <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28380</link>
		<dc:creator>Graham</dc:creator>
		<pubDate>Fri, 16 Apr 2010 16:10:04 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28380</guid>
		<description>James, I meant something like this (my own library does something similar internally):

&lt;pre lang=&quot;javascript&quot;&gt;
Group.prototype.forEach=function(fn){
	var l=this.length, wrapper=new Group([null]), i=0;
	for (;i &lt; l;i++){
		wrapper[0]=this[i];
		fn(wrapper, i, this);
		}
	};

...

var mygroup=$(&quot;p&quot;);
mygroup.forEach(function(single){
	// single is an instance
	// single[0] is the node
	});
&lt;/pre&gt;

Only one wrapper object gets created.</description>
		<content:encoded><![CDATA[<p>James, I meant something like this (my own library does something similar internally):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Group.<span class="me1">prototype</span>.<span class="me1">forEach</span><span class="sy0">=</span><span class="kw2">function</span><span class="br0">&#40;</span>fn<span class="br0">&#41;</span><span class="br0">&#123;</span>
	<span class="kw2">var</span> l<span class="sy0">=</span><span class="kw1">this</span>.<span class="me1">length</span><span class="sy0">,</span> wrapper<span class="sy0">=</span><span class="kw2">new</span> Group<span class="br0">&#40;</span><span class="br0">&#91;</span><span class="kw2">null</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">,</span> i<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span>
	<span class="kw1">for</span> <span class="br0">&#40;</span><span class="sy0">;</span>i <span class="sy0">&amp;</span>lt<span class="sy0">;</span> l<span class="sy0">;</span>i<span class="sy0">++</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
		wrapper<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">=</span><span class="kw1">this</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="sy0">;</span>
		fn<span class="br0">&#40;</span>wrapper<span class="sy0">,</span> i<span class="sy0">,</span> <span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
	<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
...
&nbsp;
<span class="kw2">var</span> mygroup<span class="sy0">=</span>$<span class="br0">&#40;</span><span class="sy0">&amp;</span>quot<span class="sy0">;</span>p<span class="sy0">&amp;</span>quot<span class="sy0">;</span><span class="br0">&#41;</span><span class="sy0">;</span>
mygroup.<span class="me1">forEach</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span>single<span class="br0">&#41;</span><span class="br0">&#123;</span>
	<span class="co1">// single is an instance</span>
	<span class="co1">// single[0] is the node</span>
	<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

<p>Only one wrapper object gets created.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28179</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 13 Apr 2010 12:43:54 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28179</guid>
		<description>@Howard, I couldn&#039;t agree more! :)</description>
		<content:encoded><![CDATA[<p>@Howard, I couldn&#8217;t agree more! <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Howard</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28143</link>
		<dc:creator>Howard</dc:creator>
		<pubDate>Fri, 09 Apr 2010 18:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28143</guid>
		<description>I would point to your first assertion: &quot;&lt;em&gt;Mr. Uber Cool jQuery Developer isn’t accustomed to the DOM&lt;/em&gt;&quot;, and point out that while jQuery is a great tool, it&#039;s not a substitute for learning the native API. If you don&#039;t know the DOM properties and methods, then &lt;strong&gt;Please Learn Them Now&lt;/strong&gt;; you&#039;ll be better for it.</description>
		<content:encoded><![CDATA[<p>I would point to your first assertion: &#8220;<em>Mr. Uber Cool jQuery Developer isn’t accustomed to the DOM</em>&#8220;, and point out that while jQuery is a great tool, it&#8217;s not a substitute for learning the native API. If you don&#8217;t know the DOM properties and methods, then <strong>Please Learn Them Now</strong>; you&#8217;ll be better for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28129</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 09 Apr 2010 09:19:37 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28129</guid>
		<description>@Simon, good point, I&#039;ll see if I can work something in.

@Graham, but there would still be implicit &quot;wrapping&quot;, which would cost just as much.</description>
		<content:encoded><![CDATA[<p>@Simon, good point, I&#8217;ll see if I can work something in.</p>
<p>@Graham, but there would still be implicit &#8220;wrapping&#8221;, which would cost just as much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham</title>
		<link>http://james.padolsey.com/javascript/76-bytes-for-faster-jquery/comment-page-1/#comment-28097</link>
		<dc:creator>Graham</dc:creator>
		<pubDate>Thu, 08 Apr 2010 12:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1517#comment-28097</guid>
		<description>I&#039;ve only starting using jQuery recently and was surprised callbacks were passed the node on its own, rather than inside a jQuery wrapper. It would have been trivial to do the above inside the jQuery core before executing each callback.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve only starting using jQuery recently and was surprised callbacks were passed the node on its own, rather than inside a jQuery wrapper. It would have been trivial to do the above inside the jQuery core before executing each callback.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

