<?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: 10 Advanced jQuery Performance Tuning Tips from Paul Irish</title>
	<atom:link href="http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/feed" rel="self" type="application/rss+xml" />
	<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish</link>
	<description>Web development and design blog from Portland based developer Jon Raasch</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:38:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: 10 Javascript Performance Boosting Tips from Nicholas Zakas &#124; Jon Raasch's Blog</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1886</link>
		<dc:creator>10 Javascript Performance Boosting Tips from Nicholas Zakas &#124; Jon Raasch's Blog</dc:creator>
		<pubDate>Wed, 10 Feb 2010 16:57:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1886</guid>
		<description>[...] the advice of industry leaders and boils it down into ten easy-to-follow guidelines. Check out 10 Advanced jQuery Performance Tips from Paul Irish and stay tuned for [...]</description>
		<content:encoded><![CDATA[<p>[...] the advice of industry leaders and boils it down into ten easy-to-follow guidelines. Check out 10 Advanced jQuery Performance Tips from Paul Irish and stay tuned for [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SohoInteractive</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1740</link>
		<dc:creator>SohoInteractive</dc:creator>
		<pubDate>Fri, 15 Jan 2010 04:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1740</guid>
		<description>Thank you for sharing. Very useful tips.
Frank</description>
		<content:encoded><![CDATA[<p>Thank you for sharing. Very useful tips.<br />
Frank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WPbud</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1739</link>
		<dc:creator>WPbud</dc:creator>
		<pubDate>Fri, 15 Jan 2010 04:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1739</guid>
		<description>Great tips. Will start digging more into html 5.</description>
		<content:encoded><![CDATA[<p>Great tips. Will start digging more into html 5.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Raasch</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1663</link>
		<dc:creator>Jon Raasch</dc:creator>
		<pubDate>Mon, 30 Nov 2009 23:07:14 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1663</guid>
		<description>Yeah it makes sense that the native JS method would be faster, thanks for taking time out from being swamped to discuss this one with me :)  If I see anything on metrics regarding this, I&#039;ll be sure to post it here.</description>
		<content:encoded><![CDATA[<p>Yeah it makes sense that the native JS method would be faster, thanks for taking time out from being swamped to discuss this one with me <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   If I see anything on metrics regarding this, I&#8217;ll be sure to post it here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Hopkins</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1662</link>
		<dc:creator>Joseph Hopkins</dc:creator>
		<pubDate>Mon, 30 Nov 2009 18:49:03 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1662</guid>
		<description>I remember in the dark recesses of my mind that document.getElementById(&#039;myId&#039;) is meant to be slightly faster than $(&#039;#myId&#039;), I haven&#039;t got metrics, (but assuming native js is always faster has stood me in good stead ;)), I think even in this very simple case jQuery isn&#039;t purely just a wrapper on document.getElementById.

As for what you are saying, yes, $obj[0] is the way to pass in the context, as you shouldn&#039;t really pass in a jQuery object* and by indexing, you are getting the html node which is what will really speed things up :)

* now if you pass in a jQuery object it can seem faster, but that is because you are doing a more specific selector on the sizzle engine rather than using a context.

Remember: 

&lt;code&gt;
$(‚Äôa&#039;, ‚Äò#myContainer‚Äô).context; // =&gt; document
&lt;/code&gt;

becomes:

&lt;code&gt;
$(‚Äô#myContainer‚Äô).find(‚Äôa&#039;);
&lt;/code&gt;

It would be interesting to see some metrics on all this, but I&#039;m up to my eyeballs in coding at the mo! :)</description>
		<content:encoded><![CDATA[<p>I remember in the dark recesses of my mind that document.getElementById(&#8216;myId&#8217;) is meant to be slightly faster than $(&#8216;#myId&#8217;), I haven&#8217;t got metrics, (but assuming native js is always faster has stood me in good stead <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ), I think even in this very simple case jQuery isn&#8217;t purely just a wrapper on document.getElementById.</p>
<p>As for what you are saying, yes, $obj[0] is the way to pass in the context, as you shouldn&#8217;t really pass in a jQuery object* and by indexing, you are getting the html node which is what will really speed things up <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>* now if you pass in a jQuery object it can seem faster, but that is because you are doing a more specific selector on the sizzle engine rather than using a context.</p>
<p>Remember: </p>
<p><code><br />
$(‚Äôa', ‚Äò#myContainer‚Äô).context; // =&gt; document<br />
</code></p>
<p>becomes:</p>
<p><code><br />
$(‚Äô#myContainer‚Äô).find(‚Äôa');<br />
</code></p>
<p>It would be interesting to see some metrics on all this, but I&#8217;m up to my eyeballs in coding at the mo! <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Raasch</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1660</link>
		<dc:creator>Jon Raasch</dc:creator>
		<pubDate>Mon, 30 Nov 2009 17:49:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1660</guid>
		<description>@joseph - Well I know you shouldn&#039;t pass a selector for the context, but what I&#039;m wondering is  whether it is more efficient to pass the getElementById() or a predefined jQuery object.  (For anyone else reading here, in Joseph&#039;s example the &lt;code&gt;$(&#039;#myContainer&#039;)[0]&lt;/code&gt; is functionally equivalent to &lt;code&gt;document.getElementById(&#039;myContainer&#039;)&lt;/code&gt;)

So let&#039;s say you have:

&lt;pre&gt;&lt;code&gt;var $obj = $(&#039;#myContainer&#039;);
&lt;/code&gt;&lt;/pre&gt;

I think what you&#039;re saying is that it&#039;s more efficient to do:

&lt;pre&gt;&lt;code&gt;$(&#039;a&#039;, $obj[0]);
&lt;/code&gt;&lt;/pre&gt;

rather than:

&lt;pre&gt;&lt;code&gt;$(&#039;a&#039;, $obj);
&lt;/code&gt;&lt;/pre&gt;

Is that right?  (And thanks again for chiming in here - I&#039;m a dork for JS performance :))</description>
		<content:encoded><![CDATA[<p>@joseph &#8211; Well I know you shouldn&#8217;t pass a selector for the context, but what I&#8217;m wondering is  whether it is more efficient to pass the getElementById() or a predefined jQuery object.  (For anyone else reading here, in Joseph&#8217;s example the <code>$('#myContainer')[0]</code> is functionally equivalent to <code>document.getElementById('myContainer')</code>)</p>
<p>So let&#8217;s say you have:</p>
<pre><code>var $obj = $('#myContainer');
</code></pre>
<p>I think what you&#8217;re saying is that it&#8217;s more efficient to do:</p>
<pre><code>$('a', $obj[0]);
</code></pre>
<p>rather than:</p>
<pre><code>$('a', $obj);
</code></pre>
<p>Is that right?  (And thanks again for chiming in here &#8211; I&#8217;m a dork for JS performance <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Hopkins</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1659</link>
		<dc:creator>Joseph Hopkins</dc:creator>
		<pubDate>Mon, 30 Nov 2009 17:35:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1659</guid>
		<description>yes, definitely should do it to get the performance benefit of context.  Passing the jQuery object still requires a search of the entire document for the reference (as it doesn&#039;t set a context)

Another way of coding it (from Brandon&#039;s site)

&quot;
// get the node for the context
var context = $(&#039;#myContainer&#039;)[0];

// pass the context as the second argument
$(&#039;a&#039;, context).context; // =&gt; 
&quot;</description>
		<content:encoded><![CDATA[<p>yes, definitely should do it to get the performance benefit of context.  Passing the jQuery object still requires a search of the entire document for the reference (as it doesn&#8217;t set a context)</p>
<p>Another way of coding it (from Brandon&#8217;s site)</p>
<p>&#8221;<br />
// get the node for the context<br />
var context = $(&#8216;#myContainer&#8217;)[0];</p>
<p>// pass the context as the second argument<br />
$(&#8216;a&#8217;, context).context; // =&gt;<br />
&#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Raasch</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1658</link>
		<dc:creator>Jon Raasch</dc:creator>
		<pubDate>Mon, 30 Nov 2009 17:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1658</guid>
		<description>Nice catch Joseph - I had meant that to use a jQuery selector for that ID.  (And yes I know how stupid it would be to use a selector for the context, I just want a selector here to make the example clearer).

But that&#039;s news to me on being able to pass document.getElementById(&#039;blah&#039;) to the jQuery context, seems like that could be useful.  Do you have any idea whether it is better performance-wise to do that rather than &lt;code&gt;$(&#039;blah&#039;).find(&#039;blah&#039;)&lt;/code&gt;?</description>
		<content:encoded><![CDATA[<p>Nice catch Joseph &#8211; I had meant that to use a jQuery selector for that ID.  (And yes I know how stupid it would be to use a selector for the context, I just want a selector here to make the example clearer).</p>
<p>But that&#8217;s news to me on being able to pass document.getElementById(&#8216;blah&#8217;) to the jQuery context, seems like that could be useful.  Do you have any idea whether it is better performance-wise to do that rather than <code>$('blah').find('blah')</code>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Hopkins</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1657</link>
		<dc:creator>Joseph Hopkins</dc:creator>
		<pubDate>Mon, 30 Nov 2009 17:20:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1657</guid>
		<description>Hi, 

Nice article, just a little catch on the context syntax,

Recommend you look at Brandon Aaron&#039;s latest blog entry:
http://brandonaaron.net/

To quote:

&quot;
$(&#039;a&#039;, &#039;#myContainer&#039;).context; // =&gt; document

When jQuery encounters another selector for the context it actually converts it to say the following instead.

$(&#039;#myContainer&#039;).find(&#039;a&#039;);
&quot;

To set the context you would either get the html element for #myContainer by indexing the jquery wrapped set and passing that in, or more preferably IMO do:

$(&#039;a&#039;, document.getElementById(&#039;myContainer&#039;));

Nice article though :)</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>Nice article, just a little catch on the context syntax,</p>
<p>Recommend you look at Brandon Aaron&#8217;s latest blog entry:<br />
<a href="http://brandonaaron.net/" rel="nofollow">http://brandonaaron.net/</a></p>
<p>To quote:</p>
<p>&#8221;<br />
$(&#8216;a&#8217;, &#8216;#myContainer&#8217;).context; // =&gt; document</p>
<p>When jQuery encounters another selector for the context it actually converts it to say the following instead.</p>
<p>$(&#8216;#myContainer&#8217;).find(&#8216;a&#8217;);<br />
&#8221;</p>
<p>To set the context you would either get the html element for #myContainer by indexing the jquery wrapped set and passing that in, or more preferably IMO do:</p>
<p>$(&#8216;a&#8217;, document.getElementById(&#8216;myContainer&#8217;));</p>
<p>Nice article though <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Raasch</title>
		<link>http://jonraasch.com/blog/10-advanced-jquery-performance-tuning-tips-from-paul-irish/comment-page-1#comment-1639</link>
		<dc:creator>Jon Raasch</dc:creator>
		<pubDate>Mon, 23 Nov 2009 16:45:01 +0000</pubDate>
		<guid isPermaLink="false">http://jonraasch.com/blog/?p=382#comment-1639</guid>
		<description>Nice catch Alex, thanks for pointing that out and sorry I didn&#039;t do my homework on that one :)</description>
		<content:encoded><![CDATA[<p>Nice catch Alex, thanks for pointing that out and sorry I didn&#8217;t do my homework on that one <img src='http://jonraasch.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
