<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jon Fox &#187; optimization</title>
	<atom:link href="http://jonefox.com/blog/tag/optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonefox.com/blog</link>
	<description>My rants, ramblings, and random thoughts</description>
	<lastBuildDate>Mon, 24 May 2010 16:12:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='jonefox.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>The Beauty Of Simplicity</title>
		<link>http://jonefox.com/blog/2009/09/11/the-beauty-of-simplicity/</link>
		<comments>http://jonefox.com/blog/2009/09/11/the-beauty-of-simplicity/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:32:44 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Introspective]]></category>
		<category><![CDATA[cruft]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[simplicity]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=205</guid>
		<description><![CDATA[It seems that no matter how hard I try, I often accumulate &#8220;cruft&#8221; in my life as I go. What I mean by &#8220;cruft&#8221; is junk and distractions that get in the way of what I&#8217;m trying to do. I find it very useful to periodically go through different areas of my life and clean [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that no matter how hard I try, I often accumulate &#8220;cruft&#8221; in my life as I go.  What I mean by &#8220;cruft&#8221; is junk and distractions that get in the way of what I&#8217;m trying to do.  I find it very useful to periodically go through different areas of my life and clean up the &#8220;cruft&#8221;.  I&#8217;ve been doing this with a lot of my online / digital self recently.  Here&#8217;s a few things I&#8217;ve been doing recently to cut down on the junk:</p>
<p>I&#8217;ve&#8230;</p>
<ul>
<li>added a bunch of new filters and/or unsubscribed from a bunch of email in an effort to keep the &#8220;bacon&#8221; (basically spam you ask for) to a minimum and keep it from getting in the way of the more important/urgent email.</li>
<li>gone through and attempted to condense down several email accounts into one Gmail account to give myself fewer points to check (and fewer mail clients to worry about).  </li>
<li>gone through my background apps (and startup apps) to cut down anything I&#8217;m not using anymore &#8211; or that just doesn&#8217;t need to run at startup.</li>
<li>&#8220;cropped&#8221; my iPhone apps and my FireFox plugins.</li>
<li>gone through a bunch of work related files on my computer and condensed / archived old stuff to get it out of the way.</li>
</ul>
<p>Sometimes it&#8217;s good to cut down on all the little stuff that gets in your way.  You might be surprised how much some of these little things can impact you when combined together.  Now if I could just tackle my closet&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/09/11/the-beauty-of-simplicity/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Front End Optimization &#8211; Part 2</title>
		<link>http://jonefox.com/blog/2008/09/21/front-end-optimization-part-2/</link>
		<comments>http://jonefox.com/blog/2008/09/21/front-end-optimization-part-2/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 05:29:50 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=76</guid>
		<description><![CDATA[One fairly common thing in javascript programming is the need to add/edit the html contents of an element on the page. It turns out that there&#8217;s actually a pretty significant performance impact on how quickly this update renders depending on how you do the actual edit. The main 5 ways to add/edit html via javascript [...]]]></description>
			<content:encoded><![CDATA[<p>One fairly common thing in javascript programming is the need to add/edit the html contents of an element on the page.  It turns out that there&#8217;s actually a pretty significant performance impact on how quickly this update renders depending on how you do the actual edit.  The main 5 ways to add/edit html via javascript are the following:</p>
<ul>
<li>Document.write() method</li>
<li>element.innerHTML (before element is in the DOM)</li>
<li>element.innerHTML (after element is in the DOM)</li>
<li>DOM manipulations on the element (before element is in the DOM)</li>
<li>DOM manipulations on the element (after the element is in the DOM)</li>
</ul>
<p>So the first thing to note is that whenever you&#8217;re faced with the question of adding/editing html before or after adding it to the DOM you should always make any changes <strong>BEFORE</strong> adding it to the DOM.  The performance difference of this is pretty significant as if the element is in the DOM the browser must immediately render the changes as the edits are taking place.  If you modify the html before attaching the element to the DOM, however, the updates stay only in memory and don&#8217;t get rendered until the edits are in place.</p>
<p>This is the single most important factor for performance in this task.  In fact, the difference is often so drastic (particularly in IE browsers) that in many cases it&#8217;s actually better to remove the element from the DOM, edit the contents, and re-attach it instead of editing it directly.  This also allows you to sidestep odd inconsistencies in IE with the innerHTML method (in some cases editing the innerHTML attribut7e of an object can cause a browser cache in IE &#8211; in particular when the element is a child of a table element).</p>
<p>Now that we know to edit contents before attaching elements to the DOM, which method should we use?  In general, the order of speeds of the methods is as follows:</p>
<ol>
<li>document.write() method</li>
<li>element.innerHTML attribute</li>
<li>DOM manipulations</li>
</ol>
<p>Document.write is consistently the fastest across browsers and is often the best method to use when it&#8217;s possible.  The main drawback of this method, however, is that it can only be used during initial browser load/rendering.  If the method is used after the page has been initially rendered it will have the undesirable effect of either crashing the browser or clearing the current page and replacing the entire page contents with the write statement instead.  This makes it unusable for adding elements after initial page load or editing the contents of an element after page load, but the pure speed/flexibility (it basically allows you to write any html to the page including inline css and javascript &#8211; though javascript tags must be written as a combined string instead a standard script tag [for example "&lt;scr"+"ipt&gt;"]) make it an option worth using when possible.</p>
<p>The next fastest method is the element.innerHTML method.  This method is very readable and easy to construct quickly in general.  One other suggestion is when concatenating strings to form the innerHTML use a temporary variable and apply it to the element only once.  For example:<br />
<code>var innerHTML = "&lt;div&gt;";<br />innerHTML += "Inner Contents";<br />innerHTML += "&lt;/div&gt;";<br />element.innerHTML = innerHTML;</code></p>
<p>This speeds up rendering (since it only has to update the DOM/render the change once) and prevents some inconsistencies when using the concatenation/assignment operators in certain browsers.</p>
<p>The last, and by far the slowest, method is to do direct DOM manipulations.  This is a broad categorization of using methods like the following:<br /><code>var element = document.createElement('DIV');<br />var element2 = document.createElement('DIV'); <br />element.appendChild(element2);</code><br />
This technique has many disadvantages.  It renders slowly as each element is added and styled as it is appended to the DOM.  Although you can improve this drastically by waiting to attach the top level element to the DOM until all the inner elements are completed, it still doesn&#8217;t compare with the previous methods described above.  This code is also much harder to read (in general) than the above methods as each style, class, and attribute of the element must be assigned individually.  This also leads to much larger code than the previous methods which adds to download time and parsing time.  This method is really only suitable when you&#8217;re editing specific attributes or doing very minor manipulations.</p>
<p>And that wraps up the 5 different methods.  Hopefully someone out there finds this helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/21/front-end-optimization-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
