<?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; Javascript</title>
	<atom:link href="http://jonefox.com/blog/tag/javascript/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>Ubiquity: PHP function lookup</title>
		<link>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/</link>
		<comments>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 03:17:15 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Ubiquity]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=72</guid>
		<description><![CDATA[So I guess I&#8217;m getting into this Ubiquity thing a bit. I&#8217;ve created another one to lookup php functions on php.net. Simply subscribe to the command here to add it to your command list. Once you&#8217;ve got the command installed you can lookup PHP functions by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;php [function]&#8220;. This [...]]]></description>
			<content:encoded><![CDATA[<p>So I guess I&#8217;m getting into this Ubiquity thing a bit.  I&#8217;ve created another one to lookup php functions on <a href="http://www.php.net">php.net</a>.  Simply subscribe to the command <a href="http://jonefox.com/ubiquity-php.htm">here</a> to add it to your command list.</p>
<p>Once you&#8217;ve got the command installed you can lookup PHP functions by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;php [function]&#8220;.  This one was pretty simple to do, but very useful already.  I look up syntax for PHP functions several times a day and saving my &#8220;Google step&#8221; is really nice.</p>
<p>Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/feed/</wfw:commentRss>
		<slash:comments>5</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>
		<item>
		<title>Ubiquity: Password Generator</title>
		<link>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/</link>
		<comments>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 05:45:10 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Password Generator]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=65</guid>
		<description><![CDATA[I recently made a stab at another Ubiquity command. This one is a password generator to generate site-specific passwords. Simply subscribe to the command here to get started. I&#8217;d suggest manually changing the &#8220;mypass&#8221; value to some unique string rather than use the default, but this is not technically required. Once you&#8217;ve got the initial [...]]]></description>
			<content:encoded><![CDATA[<p>I recently made a stab at another <a href="http://labs.mozilla.com/2008/08/introducing-ubiquity/">Ubiquity</a> command.  This one is a password generator to generate site-specific passwords.  Simply subscribe to the command <a href="http://jonefox.com/ubiquity-password.htm">here</a> to get started.  I&#8217;d suggest manually changing the &#8220;mypass&#8221; value to some unique string rather than use the default, but this is not technically required.</p>
<p>Once you&#8217;ve got the initial command setup you can generate a password by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;password&#8221;.  You can specify the site by adding it as a parameter after &#8220;password&#8221; or the command will use the current window&#8217;s location href as the default.  Passwords are an 8 character hash based on the site and the &#8220;mypass&#8221; key set at install.  The password will then be pasted at the current cursor location for your convenience.</p>
<p>Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubiquity</title>
		<link>http://jonefox.com/blog/2008/09/09/ubiquity/</link>
		<comments>http://jonefox.com/blog/2008/09/09/ubiquity/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:23:55 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=63</guid>
		<description><![CDATA[For those of you that don&#8217;t already know, Mozilla Labs recently released an early version of Ubiquity. Ubiquity is a command line interface that opens up new options to interface with your browser and integrate your web apps. Check out the video for more info. Overall I think this project is very interesting. For the [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you that don&#8217;t already know, <a href="http://labs.mozilla.com/">Mozilla Labs</a> recently released an early version of <a href="http://labs.mozilla.com/2008/08/introducing-ubiquity/">Ubiquity</a>.  Ubiquity is a command line interface that opens up new options to interface with your browser and integrate your web apps.  Check out the <a href="http://www.vimeo.com/1561578?sec=1561578">video</a> for more info.</p>
<p>Overall I think this project is very interesting.  For the techies/power users out there it provides a much more efficient way to do complex tasks.  This type of UI lends itself well to the repetitive tasks that you face on a daily basis (in particular the email commands in Ubiquity are a great example of this).  The real power of Ubiquity comes from its expandability though.  New commands can be added by adding simple javascript functions to the addon.  These additional commands can then be shared with a special link tag in a document and can even be automatically updated (if the user has given permissions for this).</p>
<p>I&#8217;ve taken a stab at my first Ubiquity command.  You can get it <a href="http://jonefox.com/ubiquity-newsgator.htm">here</a>.  It adds a command to add RSS feeds to <a href="http://newsgator.com">Newsgator</a> (my RSS reader of choice).  Just hit CTRL+SPACE (to open Ubiquity) then execute the command &#8220;add-to-newsgator&#8221; and it&#8217;ll search the current page for an RSS feed and add it to your Newsgator account.</p>
<p>What do you think of Ubiquity?</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/09/ubiquity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
