<?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: 43,439 reasons to use append() correctly</title>
	<atom:link href="http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:50:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Doug</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-84720</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Mon, 05 Dec 2011 04:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-84720</guid>
		<description>nice job. I had no idea it was so time consuming.  Will keep it in mind. Does after() and before() have the same problem? It&#039;s being used in this script: http://www.dougnorfolk.com.au/website-design-forster-notes/jquery-add-table-row-with-ajax/</description>
		<content:encoded><![CDATA[<p>nice job. I had no idea it was so time consuming.  Will keep it in mind. Does after() and before() have the same problem? It&#8217;s being used in this script: <a href="http://www.dougnorfolk.com.au/website-design-forster-notes/jquery-add-table-row-with-ajax/" rel="nofollow">http://www.dougnorfolk.com.au/website-design-forster-notes/jquery-add-table-row-with-ajax/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 100 Popular jQuery Examples, Plugins and Tutorials &#124; Agência de Criação de Sites, WebSites Descomplique &#8211; BLOG</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-84344</link>
		<dc:creator>100 Popular jQuery Examples, Plugins and Tutorials &#124; Agência de Criação de Sites, WebSites Descomplique &#8211; BLOG</dc:creator>
		<pubDate>Thu, 25 Aug 2011 12:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-84344</guid>
		<description>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</description>
		<content:encoded><![CDATA[<p>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Fisher</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-83786</link>
		<dc:creator>Patrick Fisher</dc:creator>
		<pubDate>Fri, 01 Jul 2011 19:18:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-83786</guid>
		<description>Appending is far slower than replacing. If you care about speed -- don&#039;t append, replace.

1) &lt;b&gt;Get&lt;/b&gt; the old content
2) &lt;b&gt;Concatenate&lt;/b&gt; old + new
3) &lt;b&gt;Replace&lt;/b&gt; old with old + new

&lt;code&gt;for (var i=0, l=arr.length, a=[]; i&lt;l; i++)
{
&#160;&#160;&#160;&#160;a.push(&#039;&lt;tr&gt;&lt;td name=&quot;pieTD&quot;&gt;&#039; + arr[i] + &#039;&lt;/td&gt;&lt;/tr&gt;&#039;);
}
var table = $(&#039;table&#039;);
table.html(table.html() + a.join(&#039;&#039;));&lt;/code&gt;

The get, concatenate and replace are all in the last line. For me, this is almost 4 times as fast as the method given in this article. It is also very readable.</description>
		<content:encoded><![CDATA[<p>Appending is far slower than replacing. If you care about speed &#8212; don&#8217;t append, replace.</p>
<p>1) <b>Get</b> the old content<br />
2) <b>Concatenate</b> old + new<br />
3) <b>Replace</b> old with old + new</p>
<p><code>for (var i=0, l=arr.length, a=[]; i&lt;l; i++)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;a.push('&lt;tr&gt;&lt;td name="pieTD"&gt;' + arr[i] + '&lt;/td&gt;&lt;/tr&gt;');<br />
}<br />
var table = $('table');<br />
table.html(table.html() + a.join(''));</code></p>
<p>The get, concatenate and replace are all in the last line. For me, this is almost 4 times as fast as the method given in this article. It is also very readable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kralco626</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-83718</link>
		<dc:creator>kralco626</dc:creator>
		<pubDate>Thu, 19 May 2011 13:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-83718</guid>
		<description>This is likely because it&#039;s trying to do one DOM call for each top level element. Wrapping limits the number of top level elements to one. Not sure why it&#039;s implemented this way however...</description>
		<content:encoded><![CDATA[<p>This is likely because it&#8217;s trying to do one DOM call for each top level element. Wrapping limits the number of top level elements to one. Not sure why it&#8217;s implemented this way however&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 100 Popular jQuery Examples, Plugins and Tutorials &#171; Impact Web Design Tidbits Blog</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-83669</link>
		<dc:creator>100 Popular jQuery Examples, Plugins and Tutorials &#171; Impact Web Design Tidbits Blog</dc:creator>
		<pubDate>Tue, 03 May 2011 23:13:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-83669</guid>
		<description>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</description>
		<content:encoded><![CDATA[<p>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi Morrison</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-83664</link>
		<dc:creator>Levi Morrison</dc:creator>
		<pubDate>Tue, 03 May 2011 07:47:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-83664</guid>
		<description>Though dated, this did come up highly ranked in a Google search.  Though I only skimmed other posts, it seems no one out-right said it: DOM Manipulation is SLOW!  The reason making one big string and appending once is faster has little to do with jQuery performance and lots to do with the fact that DOM operations are slow.</description>
		<content:encoded><![CDATA[<p>Though dated, this did come up highly ranked in a Google search.  Though I only skimmed other posts, it seems no one out-right said it: DOM Manipulation is SLOW!  The reason making one big string and appending once is faster has little to do with jQuery performance and lots to do with the fact that DOM operations are slow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Re : Enhance .append() to add multiple copies at a time - Jquery Home</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-81896</link>
		<dc:creator>Re : Enhance .append() to add multiple copies at a time - Jquery Home</dc:creator>
		<pubDate>Tue, 21 Sep 2010 14:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-81896</guid>
		<description>[...] $(&#8220;#container&#8221;).append(&#160;html.join(&#8221;)&#160;);  A good read:&#160;http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly [...]</description>
		<content:encoded><![CDATA[<p>[...] $(&#8220;#container&#8221;).append(&nbsp;html.join(&#8221;)&nbsp;);  A good read:&nbsp;<a href="http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly" rel="nofollow">http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mahdi pedram</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-80457</link>
		<dc:creator>mahdi pedram</dc:creator>
		<pubDate>Thu, 10 Jun 2010 09:30:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-80457</guid>
		<description>Sorry guys I forgot the &amp; gt;
&lt;pre&gt;
&lt;code&gt;
      var arr = reallyLongArray,
                textToInsert =  [&#039;&lt;tbody&gt;&#039;],
                length = arr.length,
                $table = $(table),
               chuck = 10
      for (var a = 0; a&lt;length; a += 1) {
          textToInsert.push(&#039;&lt;tr&gt;&lt;td name=&quot;pieTD&quot;&gt;&#039;);
          textToInsert.push(arr[a]);
          textToInsert.push(&#039;&lt;/td&gt;&lt;/tr&gt;&#039;) ;
         if( a % chuck == 0 ){
           $table.append(textToInsert.join(&#039;&#039;));
        }
      }
     textToInsert.push(&#039;&lt;/tbody&gt;&#039;);
    $table.append(textToInsert.join(&#039;&#039;));
&lt;/code&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Sorry guys I forgot the &amp; gt;</p>
<pre>
<code>
      var arr = reallyLongArray,
                textToInsert =  ['&lt;tbody&gt;'],
                length = arr.length,
                $table = $(table),
               chuck = 10
      for (var a = 0; a&lt;length; a += 1) {
          textToInsert.push('&lt;tr&gt;&lt;td name="pieTD"&gt;');
          textToInsert.push(arr[a]);
          textToInsert.push('&lt;/td&gt;&lt;/tr&gt;') ;
         if( a % chuck == 0 ){
           $table.append(textToInsert.join(''));
        }
      }
     textToInsert.push('&lt;/tbody&gt;');
    $table.append(textToInsert.join(''));
</code>
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: mahdi pedram</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-80456</link>
		<dc:creator>mahdi pedram</dc:creator>
		<pubDate>Thu, 10 Jun 2010 09:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-80456</guid>
		<description>Thanks for your fantastic post .
I will personally go this way when we really have a long array we have to add the data to the DOM chuck by chuck so it doesn&#039;t freezes the page .
I encourage using setTimeout and having the for loop inside a function . 
we could avoid creating a i variable and doing i++ each time instead we can use array.push


&lt;pre&gt;&lt;code&gt;
      var arr = reallyLongArray,
                textToInsert =  [&#039;&#039;],
                length = arr.length, 
                $table = $(table), 
               chuck = 10
      for (var a = 0; a &lt;length; a += 1) {
          textToInsert.push(&#039;&#039;);
          textToInsert.push(arr[a]);
          textToInsert.push(&#039; &#039;) ;
         if( a % chuck == 0 ){  
           $table.append(textToInsert.join(&#039;&#039;));   
        }
      }
     textToInsert.push(&#039;&#039;);
    $table.append(textToInsert.join(&#039;&#039;));


&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thanks for your fantastic post .<br />
I will personally go this way when we really have a long array we have to add the data to the DOM chuck by chuck so it doesn&#8217;t freezes the page .<br />
I encourage using setTimeout and having the for loop inside a function .<br />
we could avoid creating a i variable and doing i++ each time instead we can use array.push</p>
<pre><code>
      var arr = reallyLongArray,
                textToInsert =  [''],
                length = arr.length,
                $table = $(table),
               chuck = 10
      for (var a = 0; a &lt;length; a += 1) {
          textToInsert.push(&#039;');
          textToInsert.push(arr[a]);
          textToInsert.push(' ') ;
         if( a % chuck == 0 ){
           $table.append(textToInsert.join(''));
        }
      }
     textToInsert.push('');
    $table.append(textToInsert.join(''));

</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: jQuery Plugins - Nagpur City</title>
		<link>http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly/comment-page-1#comment-80411</link>
		<dc:creator>jQuery Plugins - Nagpur City</dc:creator>
		<pubDate>Wed, 02 Jun 2010 13:05:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/?p=542#comment-80411</guid>
		<description>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</description>
		<content:encoded><![CDATA[<p>[...] a particular array all the methods that Prototype adds to their Array and Enumerable objects. 85. 43,439 Reasons to Use Append() Correctly – This technique provides for the proper way of using this jQuery method. Although an extremely [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 6/20 queries in 0.006 seconds using disk: basic
Object Caching 371/376 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-08 17:37:31 -->
