<?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: jQuery code smells</title>
	<atom:link href="http://james.padolsey.com/javascript/jquery-code-smells/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/jquery-code-smells/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 09 Sep 2010 12:32:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jeremy</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-29703</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Fri, 20 Aug 2010 22:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-29703</guid>
		<description>The jQuery developers themselves use $var in the jQuery code.  It&#039;s an extremely useful way of differentiating a jQuery results object from the (very similar) raw HTML element object (or any other type of var for that matter, but that&#039;s the specific case I believe it&#039;s designed for).

var div;

Is that an HTML div, or a $(&quot;div&quot;)?  I have no idea.  Unless I use:

var $div;

regularly, in which case I know with certainty without having to scroll back up through my code to find out.

So yeah: this article smells :-(</description>
		<content:encoded><![CDATA[<p>The jQuery developers themselves use $var in the jQuery code.  It&#8217;s an extremely useful way of differentiating a jQuery results object from the (very similar) raw HTML element object (or any other type of var for that matter, but that&#8217;s the specific case I believe it&#8217;s designed for).</p>
<p>var div;</p>
<p>Is that an HTML div, or a $(&#8220;div&#8221;)?  I have no idea.  Unless I use:</p>
<p>var $div;</p>
<p>regularly, in which case I know with certainty without having to scroll back up through my code to find out.</p>
<p>So yeah: this article smells <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous Coward</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26349</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Mon, 01 Feb 2010 12:13:26 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26349</guid>
		<description>&quot;When performance is a prime concern, then frankly, I wouldn’t necessarily recommend using jQuery in the first place.&quot;

Agreed. Personally, I like MooTools better.</description>
		<content:encoded><![CDATA[<p>&#8220;When performance is a prime concern, then frankly, I wouldn’t necessarily recommend using jQuery in the first place.&#8221;</p>
<p>Agreed. Personally, I like MooTools better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eligmatic</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26264</link>
		<dc:creator>eligmatic</dc:creator>
		<pubDate>Sat, 23 Jan 2010 14:53:17 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26264</guid>
		<description>My pet-hate at the moment is so-called &quot;prettified&quot; code. Please God, it ain&#039;t f***-in legible!!!</description>
		<content:encoded><![CDATA[<p>My pet-hate at the moment is so-called &#8220;prettified&#8221; code. Please God, it ain&#8217;t f***-in legible!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Tulett</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26219</link>
		<dc:creator>Nick Tulett</dc:creator>
		<pubDate>Tue, 19 Jan 2010 15:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26219</guid>
		<description>Inspired by this article, I&#039;ve been on an .each() hunt of my own code and eliminated almost all of them. 

Of course 1.4&#039;s ability to do things like 
&lt;pre lang=&quot;javascript&quot;&gt;$(&quot;#foo td:nth-child(2)&quot;).text(function(i, currentText){
  return currentText + &quot;bar&quot;;
})&lt;/pre&gt;
may be an .each() in disguise but the performance improvements mean I no longer care (despite what I said in the bad old days of 1.3)</description>
		<content:encoded><![CDATA[<p>Inspired by this article, I&#8217;ve been on an .each() hunt of my own code and eliminated almost all of them. </p>
<p>Of course 1.4&#8217;s ability to do things like</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">&quot;#foo td:nth-child(2)&quot;</span><span class="br0">&#41;</span>.<span class="me1">text</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span>i<span class="sy0">,</span> currentText<span class="br0">&#41;</span><span class="br0">&#123;</span>
  <span class="kw1">return</span> currentText <span class="sy0">+</span> <span class="st0">&quot;bar&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span></pre></div></div>

<p>may be an .each() in disguise but the performance improvements mean I no longer care (despite what I said in the bad old days of 1.3)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26181</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Fri, 15 Jan 2010 18:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26181</guid>
		<description>I wondered what I could smell Eliazer. Surely there was another method you could use?</description>
		<content:encoded><![CDATA[<p>I wondered what I could smell Eliazer. Surely there was another method you could use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eliazer Braun</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26180</link>
		<dc:creator>Eliazer Braun</dc:creator>
		<pubDate>Fri, 15 Jan 2010 16:26:33 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26180</guid>
		<description>Great read 
is this too much chaining?

&lt;pre lang=&quot;javascript&quot;&gt;
     $(&quot;.seeAllTestimonials&quot;).toggle(function(){
		if(!isAnimating){
			isAnimating = true;
			isInFullView = true;
				$(this).html(&quot;Back&quot;)
				.siblings(&quot;ul&quot;)
				.stop()
				.css({&quot;top&quot;:0,&quot;opacity&quot;:1.0})
				.fadeOut(500)
				.focus()
				.find(&quot;li:last&quot;)
				.addClass(&quot;lastTestimonial&quot;)
				.parent()
				.parent()
				.parent()
				.addClass(&quot;viewAll&quot;)
				.animate({width:697+&quot;px&quot;}, 1000)
				.find(&quot;.testimonialsCntnr&quot;)
				.animate({width:697+&quot;px&quot;}, 1000, 
					function(){
						$(&quot;.seeAllTestimonials&quot;)
						.siblings(&quot;ul&quot;)
						.addClass(&quot;isFullyOpen&quot;)
						.fadeIn(500);
						testimonialsBelt.resetBelt();
						isAnimating = false;
					 });
			}
	},
	function(){
		if(!isAnimating){
			isAnimating = true;
			isInFullView = false;
			$(this).html(&quot;See all testimonials&quot;)
				.siblings(&quot;ul&quot;)
				.fadeOut(500)
				.children()
				.removeAttr(&quot;class&quot;)
				.parent()
				.parent()
				.parent()
				.animate({width:200+&quot;px&quot;}, 1000)
				.find(&quot;.testimonialsCntnr&quot;)
				.animate({width:200+&quot;px&quot;}, 1000, 
					function(){
						$(&quot;.seeAllTestimonials&quot;).siblings(&quot;ul&quot;)
						.removeClass(&quot;isFullyOpen&quot;)
						.fadeIn(500)
						.end()
						.parent()
						.parent()
						.removeClass(&quot;viewAll&quot;);
						isAnimating = false;
						testimonialsBelt.resetBelt();
					});											
		    	}
		});
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Great read<br />
is this too much chaining?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">     $<span class="br0">&#40;</span><span class="st0">&quot;.seeAllTestimonials&quot;</span><span class="br0">&#41;</span>.<span class="me1">toggle</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
		<span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>isAnimating<span class="br0">&#41;</span><span class="br0">&#123;</span>
			isAnimating <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
			isInFullView <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
				$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">&quot;Back&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">siblings</span><span class="br0">&#40;</span><span class="st0">&quot;ul&quot;</span><span class="br0">&#41;</span>
				.<span class="kw3">stop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">css</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="st0">&quot;top&quot;</span><span class="sy0">:</span><span class="nu0">0</span><span class="sy0">,</span><span class="st0">&quot;opacity&quot;</span><span class="sy0">:</span><span class="nu0">1.0</span><span class="br0">&#125;</span><span class="br0">&#41;</span>
				.<span class="me1">fadeOut</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span>
				.<span class="kw3">focus</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&quot;li:last&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;lastTestimonial&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;viewAll&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">animate</span><span class="br0">&#40;</span><span class="br0">&#123;</span>width<span class="sy0">:</span><span class="nu0">697</span><span class="sy0">+</span><span class="st0">&quot;px&quot;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="nu0">1000</span><span class="br0">&#41;</span>
				.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&quot;.testimonialsCntnr&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">animate</span><span class="br0">&#40;</span><span class="br0">&#123;</span>width<span class="sy0">:</span><span class="nu0">697</span><span class="sy0">+</span><span class="st0">&quot;px&quot;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="nu0">1000</span><span class="sy0">,</span> 
					<span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
						$<span class="br0">&#40;</span><span class="st0">&quot;.seeAllTestimonials&quot;</span><span class="br0">&#41;</span>
						.<span class="me1">siblings</span><span class="br0">&#40;</span><span class="st0">&quot;ul&quot;</span><span class="br0">&#41;</span>
						.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&quot;isFullyOpen&quot;</span><span class="br0">&#41;</span>
						.<span class="me1">fadeIn</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span><span class="sy0">;</span>
						testimonialsBelt.<span class="me1">resetBelt</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
						isAnimating <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span>
					 <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			<span class="br0">&#125;</span>
	<span class="br0">&#125;</span><span class="sy0">,</span>
	<span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
		<span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>isAnimating<span class="br0">&#41;</span><span class="br0">&#123;</span>
			isAnimating <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
			isInFullView <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span>
			$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">&quot;See all testimonials&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">siblings</span><span class="br0">&#40;</span><span class="st0">&quot;ul&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">fadeOut</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span>
				.<span class="me1">children</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">removeAttr</span><span class="br0">&#40;</span><span class="st0">&quot;class&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
				.<span class="me1">animate</span><span class="br0">&#40;</span><span class="br0">&#123;</span>width<span class="sy0">:</span><span class="nu0">200</span><span class="sy0">+</span><span class="st0">&quot;px&quot;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="nu0">1000</span><span class="br0">&#41;</span>
				.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&quot;.testimonialsCntnr&quot;</span><span class="br0">&#41;</span>
				.<span class="me1">animate</span><span class="br0">&#40;</span><span class="br0">&#123;</span>width<span class="sy0">:</span><span class="nu0">200</span><span class="sy0">+</span><span class="st0">&quot;px&quot;</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="nu0">1000</span><span class="sy0">,</span> 
					<span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
						$<span class="br0">&#40;</span><span class="st0">&quot;.seeAllTestimonials&quot;</span><span class="br0">&#41;</span>.<span class="me1">siblings</span><span class="br0">&#40;</span><span class="st0">&quot;ul&quot;</span><span class="br0">&#41;</span>
						.<span class="me1">removeClass</span><span class="br0">&#40;</span><span class="st0">&quot;isFullyOpen&quot;</span><span class="br0">&#41;</span>
						.<span class="me1">fadeIn</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span>
						.<span class="me1">end</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
						.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
						.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
						.<span class="me1">removeClass</span><span class="br0">&#40;</span><span class="st0">&quot;viewAll&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
						isAnimating <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span>
						testimonialsBelt.<span class="me1">resetBelt</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
					<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>											
		    	<span class="br0">&#125;</span>
		<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Tulett</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26135</link>
		<dc:creator>Nick Tulett</dc:creator>
		<pubDate>Tue, 12 Jan 2010 22:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26135</guid>
		<description>&lt;blockquote&gt;When performance is a prime concern, then frankly, I wouldn’t necessarily recommend using jQuery in the first place.&lt;/blockquote&gt;
Alternatively, if you&#039;re already using jQuery for other reasons then you should be concerned with gaining the best performance. 
It&#039;s not necessarily true that new browsers are universally faster and in any case &lt;strong&gt;someone&lt;/strong&gt; has to pay the price for inefficient code whether it&#039;s time, disk wear or electricity bills.</description>
		<content:encoded><![CDATA[<blockquote><p>When performance is a prime concern, then frankly, I wouldn’t necessarily recommend using jQuery in the first place.</p></blockquote>
<p>Alternatively, if you&#8217;re already using jQuery for other reasons then you should be concerned with gaining the best performance.<br />
It&#8217;s not necessarily true that new browsers are universally faster and in any case <strong>someone</strong> has to pay the price for inefficient code whether it&#8217;s time, disk wear or electricity bills.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TJ</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26118</link>
		<dc:creator>TJ</dc:creator>
		<pubDate>Mon, 11 Jan 2010 20:31:42 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26118</guid>
		<description>I agree with most of the responses concerning the appending html section. I just think trying to abstract things, trying to make them look more &#039;readable,&#039; or attempting to use better programming practice is simply the wrong philosophy here.

As Josh Powell said, performance is clearly an issue. 

To build off of that, maintainability is much simpler with one append than it is with your solution, The only reason anything should ever become more &#039;complex&#039; (from the readability standpoint) is to improve efficiency or performance. In this case, this simply doesn&#039;t cut it.</description>
		<content:encoded><![CDATA[<p>I agree with most of the responses concerning the appending html section. I just think trying to abstract things, trying to make them look more &#8216;readable,&#8217; or attempting to use better programming practice is simply the wrong philosophy here.</p>
<p>As Josh Powell said, performance is clearly an issue. </p>
<p>To build off of that, maintainability is much simpler with one append than it is with your solution, The only reason anything should ever become more &#8216;complex&#8217; (from the readability standpoint) is to improve efficiency or performance. In this case, this simply doesn&#8217;t cut it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Curran</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26117</link>
		<dc:creator>James Curran</dc:creator>
		<pubDate>Mon, 11 Jan 2010 15:37:23 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26117</guid>
		<description>In your HTML example, your &quot;non-smelly&quot; code leaves out the link text &quot;Linky&quot;. Adding this is no problem (&lt;code&gt;$(&#039;&lt;a/&gt;&#039;).text(&quot;Linky&quot;).click(function(){ ...&lt;/code&gt;)
but it adds another function call, and makes your &quot;more readable&quot; code a bit more removed from the actual HTML.

On the whole, I think, I&#039;d probably go for something like this:

&lt;pre lang=&quot;javascript&quot;&gt;
var div = $(&#039;&lt;a&gt;Linky&lt;/a&gt;&#039;);
$(&#039;a&#039;, div).click(function(){ return false; })
// rest as above.
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>In your HTML example, your &#8220;non-smelly&#8221; code leaves out the link text &#8220;Linky&#8221;. Adding this is no problem (<code>$('&lt;a/&gt;').text("Linky").click(function(){ ...</code>)<br />
but it adds another function call, and makes your &#8220;more readable&#8221; code a bit more removed from the actual HTML.</p>
<p>On the whole, I think, I&#8217;d probably go for something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> div <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'&lt;a&gt;Linky&lt;/a&gt;'</span><span class="br0">&#41;</span><span class="sy0">;</span>
$<span class="br0">&#40;</span><span class="st0">'a'</span><span class="sy0">,</span> div<span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>
<span class="co1">// rest as above.</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: nickf</title>
		<link>http://james.padolsey.com/javascript/jquery-code-smells/comment-page-1/#comment-26106</link>
		<dc:creator>nickf</dc:creator>
		<pubDate>Sun, 10 Jan 2010 13:14:32 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=1344#comment-26106</guid>
		<description>I&#039;m very much in the pro-camp on prefixing jQuery objects with &lt;code&gt;$&lt;/code&gt;. It makes your intentions so much more obvious. Consider this:
&lt;pre lang=&quot;javascript&quot;&gt;
function showDiv($div) {
    // whatever
}&lt;/pre&gt;
You know immediately just by looking at the method signature what type of object is expected. You never have to search back through your code to see if &lt;code&gt;$div&lt;/code&gt; is a jQuery object or just a plain DOM Element.

Regarding &lt;code&gt;.append()&lt;/code&gt; being very slow: You&#039;ll get differing results depending on what you&#039;re appending to. If you&#039;re appending to an element which is in the document, then the browser has to recalculate styles which is a relatively expensive operation. If you&#039;re adding to something which isn&#039;t in the DOM yet, then it only needs to do this once at the end and it&#039;s much faster.</description>
		<content:encoded><![CDATA[<p>I&#8217;m very much in the pro-camp on prefixing jQuery objects with <code>$</code>. It makes your intentions so much more obvious. Consider this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">function</span> showDiv<span class="br0">&#40;</span>$div<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="co1">// whatever</span>
<span class="br0">&#125;</span></pre></div></div>

<p>You know immediately just by looking at the method signature what type of object is expected. You never have to search back through your code to see if <code>$div</code> is a jQuery object or just a plain DOM Element.</p>
<p>Regarding <code>.append()</code> being very slow: You&#8217;ll get differing results depending on what you&#8217;re appending to. If you&#8217;re appending to an element which is in the document, then the browser has to recalculate styles which is a relatively expensive operation. If you&#8217;re adding to something which isn&#8217;t in the DOM yet, then it only needs to do this once at the end and it&#8217;s much faster.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
