<?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>Seifi.org &#187; javascript</title>
	<atom:link href="http://www.seifi.org/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.seifi.org</link>
	<description>A Web Development Blog by Joe Seifi - seifi.org</description>
	<lastBuildDate>Thu, 26 Jan 2012 01:08:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimizing the Google +1 button for speed</title>
		<link>http://www.seifi.org/javascript/optimizing-the-google-1-button-for-speed.html</link>
		<comments>http://www.seifi.org/javascript/optimizing-the-google-1-button-for-speed.html#comments</comments>
		<pubDate>Fri, 17 Jun 2011 20:38:43 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=812</guid>
		<description><![CDATA[If you&#8217;re like most bloggers and site owners, you&#8217;ve probably already added or are planning to add the new Google +1 button to your website, to go along with the Twitter and Facebook buttons. Having implemented the +1 button I&#8217;ve found that the script takes a long time to load, and does not even load [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like most bloggers and site owners, you&#8217;ve probably already added or are planning to add the new Google +1 button to your website, to go along with the Twitter and Facebook buttons. Having implemented the +1 button I&#8217;ve found that the script takes a long time to load, and does not even load if you&#8217;re on an iPhone or iPad. This actually comes as a shock to me considering Google itself is a huge advocate of page speed improvements. The file (plusone.js) is 4 KB (before gzipping) and gets assigned a short expiration time of only 60 minutes by Google. Thankfully the script is gzipped and is only semi-minified, but it still takes a new uncached hit about 1.26 seconds to complete. Most of this time is spent in either the Blocking or Waiting stages, which might have something to do with it being served from a secure server. The decision to load the file over HTTPS by default is a bit baffling to me, especially since the handshake is historically slower. Unless sensitive information exists in the JS code which could be another interesting topic. Google has been doing some work on <a href="http://blog.chromium.org/2011/05/ssl-falsestart-performance-results.html" target="_blank">SSL FalseStart</a> in Chrome to alleviate SSL latency and it seems their goal is to eventually serve all their services securely. Plusone.js then loads a second much larger js file from plusone.google.com also over SSL which comes in at about 57 KB (before gzipping). This file tacks on another 1.17 seconds to the completion time for the +1 button.</p>
<p>After seeing how slow the Google +1 button loads and how it can actually degrade your website&#8217;s overall pageload time, I started looking around for answers. First of all, I found that I&#8217;m not the only one complaining about the issue. Numerous others have started to point out the speed issues with the +1 button. My second thought was to perhaps remove the button from the site, although considering the effect the +1 button has on your website&#8217;s ranking that would mean less love from Google. </p>
<p>So what&#8217;s a developer to do? If we keep the button on our site, overall pageload times spike. But if we remove the button, or not add it, we might lose out on a potential piece of the social voting pie which most believe affects your search performance. </p>
<p>So here are my techniques for making Google +1 button load faster, or at least not slow down your site. Interestingly enough these techniques are the same set of tips and tricks that Google&#8217;s own <a href="http://code.google.com/speed/page-speed/" target="_blank">Page Speed</a> recommends for webmasters.</p>
<h3>1) Save a step, Use Https</h3>
<p>Make sure you use the HTTPS protocol in the URL for the JavaScript source, as the original version of the button snippets given out by Google included the HTTP version http://apis.google.com/js/plusone.js which just does a redirect to https://apis.google.com/js/plusone.js This issue has since been corrected by Google when you use Google&#8217;s <a href="http://www.google.com/webmasters/+1/button/" target="_blank">+1 button generator</a> site.</p>
<h3>2) Don&#8217;t load the script on Mobile devices</h3>
<p>As stated by Google, currently the Google +1 button does not support <a href="http://www.google.com/support/forum/p/Webmasters/thread?tid=6da5296e3d7207e2" target="_blank">mobile devices</a> like the iPhone, iPod touch, iPad, or Android. This means if you have the button code on a mobile site you&#8217;re basically wasting HTTP connections and adding extra weight to your site&#8217;s throughput. To get around this fact you need to write a little utility function in JavaScript that sniffs the userAgent for unsupported devices, and only makes a call to the script if your client is not one of those devices.<br />
For example in the case of an iPhone and iPad website, you would do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> isMobileUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iphone|ipod|ipad|android|blackberry|mini|windows\sce|palm/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isMobileUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//include the plusone.js code here</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>3) Load the plusone.js script asynchronously</h3>
<p>HTML 5 has introduced the ability to load scripts asynchronously allowing the rest of the page to load independently of potential bottlenecks. This feature is actually already in use for the Google Analytics code. Keep in mind that only Chrome and Firefox 3.6 and above <a href="http://www.browserscope.org/?category=network" target="_blank">support</a> the <a href="http://www.whatwg.org/specs/web-apps/current-work/#attr-script-async" target="_blank">async</a> feature at this time. But it does not hurt your non-supporting browsers in any way so it&#8217;s safe to use. Here&#8217;s the code that combines the check for unsupported mobile browsers from before to load the +1 button script asynchronously. Note that since this code is loaded asynchronously it doesn&#8217;t matter if you put the call in the footer or header.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> isMobileUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/iphone|ipod|ipad|android|blackberry|mini|windows\sce|palm/i</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isMobileUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// create a new script element in the DOM</span>
<span style="color: #003366; font-weight: bold;">var</span> gp1script <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// set it's type attribute, not really needed in HTML 5 but just to be safe</span>
gp1script.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'text/javascript'</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// set the HTML 5 attribute of async to true for the script tag</span>
gp1script.<span style="color: #660066;">async</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// set the source attribute to the https version of the google pluseone code</span>
<span style="color: #006600; font-style: italic;">// change this to your own server path if you are cosidering using option 4 below</span>
gp1script.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'https://apis.google.com/js/plusone.js'</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// add the new script tag to the head or body of the page</span>
<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">||</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>gp1script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You would then place the tag where you want the +1 button to render, which since it is a proprietry tag will just be ignored if the script is not present on your page.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;g:plusone&gt;&lt;/g:plusone&gt;</pre></div></div>

<p>If you&#8217;re not comfortable with the <g> tag, you can also use an HTML 5 version to render the +1 button on your site, which uses a css class of g-plusone and sets attributes as needed. For example you can display a standard +1 button with counts using this HTML 5 tag.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;g-plusone&quot; data-size=&quot;standard&quot; data-count=&quot;true&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>Note that you can also place multiple +1 buttons on a single page. For example you might have a +1 button that directs its vote to your main parent homepage like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;g:plusone href=&quot;http://www.your_tld.com/&gt;&lt;/g:plusone&gt;</pre></div></div>

<h3>4) Host the plusone.js file yourself</h3>
<p>This option has been suggested by some users, although I personally argue against it just because you&#8217;ll be responsible for continuously monitoring changes and updating your version. The big benefit here is avoiding that dreaded HTTPS server, but keep in mind the script still will make that second call to load the plusone library so you&#8217;re still not home free. Only go this route if you&#8217;re seriously considering a site improvement and are willing and capable of pushing out updates to your version of the script. I&#8217;m sure the Google +1 team is making lots of changes and adding bug fixes which you will miss out on if you forget to update the script on a daily basis. In the extreme case you could perhaps write a program that downloads the latest version of the script from Google&#8217;s servers and updates your version on a daily basis, but then again this becomes a new task to keep an eye on.</p>
<p>Hope this helps and let me know if you have other tips and or feedback regarding these ideas. For more details be sure to read the +1 button <a href="http://code.google.com/apis/+1button/" target="_blank">API</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/optimizing-the-google-1-button-for-speed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wishlist: Browsers contain major JavaScript libraries in memory</title>
		<link>http://www.seifi.org/javascript/wishlist-browsers-contain-major-javascript-libraries-in-memory.html</link>
		<comments>http://www.seifi.org/javascript/wishlist-browsers-contain-major-javascript-libraries-in-memory.html#comments</comments>
		<pubDate>Fri, 06 Mar 2009 08:18:01 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=726</guid>
		<description><![CDATA[Let&#8217;s face it, without JavaScript the web would be a boring place. Unless you roll your own, well you need to use a library of some sort, and in most cases you need more than just one library to achieve your intended user experience. Performance optimizations aside, and even if you concatenate all your JS [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it, without JavaScript the web would be a boring place. Unless you roll your own, well you need to use a library of some sort, and in most cases you need more than just one library to achieve your intended user experience.</p>
<p>Performance optimizations aside, and even if you concatenate all your JS files into a single file, you still have to load the library into the browser after the request has been made, and you can&#8217;t do anything with it until that has finished loading.</p>
<p>Wouldn&#8217;t it be so great if the browser had a copy of YUI or jQuery or Dojo or Prototype or GWT in memory at all times? Then your library using decision would not be influenced by the size of the library but by its speed and performance, and perhaps features and functionality provided. I mean you don&#8217;t go loading new fonts and new plugins every single time you go to a new page right? Then why do we have to download the same 5 or 6 JS libraries over and over all day long as we browse the web? And if this was an option how many companies would spend time rolling out their own rather than adopting one?</p>
<p>I understand there would be tons of politics involved and it will probably never happen in a million years but it is worth a try. Perhaps at least a FF only version could be done through an add-on that loads the latest major version of all these libraries and checks for updates on startup, similar to how other plugins get updated in FireFox today. The browser would have to namespace the libraries to avoid confusion. Developers would then just do a test to see if the browser has a required library in memory, and if not then make a server call for it as a fail safe. </p>
<p>It would take lots of collaboration and standardization. JavaScript was the sleeping giant that was brought to center stage with the success of frameworks and libraries that have fueled its standardization and resulting wider adoption. Why not give those libraries some credit and package them into your browsers?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/wishlist-browsers-contain-major-javascript-libraries-in-memory.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Google Chrome First Impressions</title>
		<link>http://www.seifi.org/javascript/google-chrome-first-impressions.html</link>
		<comments>http://www.seifi.org/javascript/google-chrome-first-impressions.html#comments</comments>
		<pubDate>Tue, 02 Sep 2008 19:02:35 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=677</guid>
		<description><![CDATA[Yet another browser? Well here we go again. Let&#8217;s take a look at Chrome and see what it has to offer. The download page is located here. The installer for Windows XP is only 474KB! You can watch the press conference video about Google Chrome or read the Google Chrome Book in the meantime. What [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.seifi.org/wp-content/uploads/2008/09/googlechromelogo.jpg" alt="" title="Google Chrome Logo" width="55" height="53" class="alignnone size-full wp-image-683" hspace="15" align="right" />Yet another browser? Well here we go again. Let&#8217;s take a look at Chrome and see what it has to offer. The download page is <a href="http://www.google.com/chrome">located here</a>. The installer for Windows XP is only 474KB! You can watch the <a href="http://google.client.shareholder.com/Visitors/event/build2/MediaPresentation.cfm?MediaID=33101&#038;Player=1">press conference video</a> about Google Chrome or read the <a href="http://www.google.com/googlebooks/chrome/index.html">Google Chrome Book</a> in the meantime.</p>
<h3>What we knew so far about Chrome</h3>
<ul>
<li>Uses <a href="http://code.google.com/apis/v8/">V8 JavaScript engine</a> which supports Classes and compilation. There is a <a href="http://code.google.com/apis/v8/run.html">V8 JavaScript benchmark suite</a> that gives FireFox 3 a score of 83, while giving Chrome a score of 1213! Safari 3 gets a score of 128. Judging by this alone, V8 blows away the competition.</li>
<li>Uses Webkit rendering engine.</li>
<li>Tabs run as independent processes which can be managed.</li>
<li>Lots of other <a href="http://gears.google.com/chrome/intl/en/features.html">features</a>.</li>
</ul>
<h3>First Impressions</h3>
<ul>
<li>Installation was a breeze and imported FireFox settings.</li>
<li>No status bar, You only see the status bar when you hover over a hyperlink.</li>
<li>The Task Manager (Shift + Escape) updates in real time and shows memory, CPU and network usage for each tab, each plugin, and the main Chrome process separately. There is also a link to Stats for Nerds with lots more gritty info.</li>
<li>The Flash plugin is extremely CPU usage intensive and causes sluggishness when scrolling. I just loaded a popular <a href="http://www.adobe.com/products/acrobat/">flash website</a> and noticed my machine came down to a near halt. It seems to happen more with Flash files that contain infinite loops, using as much as 70% of the CPU.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/09/chrome_taskmanager_cpu.gif" alt="" title="Chrome Task Manager CPU Usage" width="377" height="164" class="alignnone size-full wp-image-681" />
</li>
<li>The built in JavaScript console looks like a combination of <a href="http://www.seifi.org/javascript/firebug_tips_and_tricks.html">FireBug</a> and <a href="http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html">Web Inspector</a>.</li>
<li>There is a built in JavaScript Debugger (Alt + `)</li>
<li>Passes the <a href="http://www.webstandards.org/files/acid2/test.html">Acid 2 test</a>.</li>
<li>Chrome gets a score of 78 on the <a href="http://acid3.acidtests.org/">Acid 3 test</a>, which is higher than FireFox 3 at 57, <a href="http://webkit.org/blog/158/the-acid-3-test/">Safari</a> at 72, and Opera at 45.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/09/chrome_acid3.gif" alt="" title="Chrome Acid 3 Results" width="450" height="369" class="alignnone size-full wp-image-682" />
</li>
<li>Omnibar &#8211; this is the URL/location bar in Chrome that has some fuzzy logic built in to suggest &#8220;smart&#8221; autocompletes. This is the current order of the drop down in the auto complete list. There seems to be no way of changing this ordering as of now. Would be nice to be able to customize them.<br />
&nbsp;<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/09/omnibar.gif" alt="" title="Google Chrome Omnibar - Search Amazon" width="396" height="173" /><br />
&nbsp;</p>
<ol>
<li>Search Google for FOOBAR</li>
<li>FOOBAR/ (I&#8217;m not sure how useful this one is really)</li>
<li>Link to the FOOBAR Wikipedia page</li>
<li>Link to I&#8217;m Feeling Lucky URL for term FOOBAR. This item gives you the ability to search within the URL. For example if you type in Amazon in the Omnibar and select the amazon.com option using the down arrows, you will see &#8220;Press Tab to Search Amazon&#8221;. See below instruction on implementing this search functionality for your website.
</li>
<li>Search Google for FOOBAR ANOTHER TERM</li>
<li>Search Google for FOOBAR ANOTHER TERM</li>
<li>A page in your history pertaining to FOOBAR</li>
<li>Link to history search for pages about FOOBAR</li>
</ol>
</li>
</ul>
<h3>Cool Developer related stuff in Chrome</h3>
<p>Google Chrome User Agent String: </p>
<blockquote><p>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13.</p></blockquote>
<p>Chrome has a menu option called &#8220;Create application shortcuts&#8230;&#8221; that uses Google Gears to create a shortcut to your webapp. Users can choose to place the shortcut to your webapp on their Desktop, on the Start menu and even the Quick launch bar in Windows. This is a pretty powerful feature. When a user clicks this icon, Chrome opens up without the Omnibar, and your website will appear in an &#8220;Application&#8221; format. You can customize how Chrome creates these shortcuts using meta tags. These tags are named: application-name, description, application-url, and shortcut icons in both 32&#215;32 or 48&#215;48 formats. The favicon is used if not specified. For example you can use the following HTML code in the head of your document. Note that with the Mozilla added support which is used in Chrome, you can use any supported graphic format as your favicon, and not just the old school <a href="http://en.wikipedia.org/wiki/Favicon">favicon.ico</a> file.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;head&gt;
  &lt;meta name=&quot;application-name&quot; content=&quot;Gmail&quot;/&gt;
  &lt;meta name=&quot;description&quot; content=&quot;Google's approach to email&quot;/&gt;
  &lt;meta name=&quot;application-url&quot; content=&quot;http://www.gmail.com&quot;/&gt;
  &lt;link rel=&quot;icon&quot; href=gmail_32x32.png sizes=&quot;32x32&quot;/&gt;
  &lt;link rel=&quot;icon&quot; href=gmail_48x48.png sizes=&quot;48x48&quot;/&gt;
&lt;/head&gt;</pre></div></div>

<p>To open a new tab from your webapp in a separate process using JavaScript you can do this in Chrome.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> w <span style="color: #339933;">=</span> window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
w.<span style="color: #660066;">opener</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
w.<span style="color: #660066;">document</span>.<span style="color: #660066;">location</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://differentsite.com/index.html&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Chrome lets users search your website from its ominbar. To enable and include your website&#8217;s search in Chrome you have to create an <a href="http://www.opensearch.org">OpenSearch</a> description document (OSDD).<br />
For example you can create something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;OpenSearchDescription</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://a9.com/-/spec/opensearch/1.1/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ShortName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Web Search<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ShortName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Use Example.com to search the Web.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Tags<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>example web<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Tags<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Contact<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>admin@example.com<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Contact<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Url</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;application/atom+xml&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;http://example.com/?q={searchTerms}&amp;amp;pw={startPage?}&amp;amp;format=atom&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Url</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;application/rss+xml&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;http://example.com/?q={searchTerms}&amp;amp;pw={startPage?}&amp;amp;format=rss&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Url</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/html&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;http://example.com/?q={searchTerms}&amp;amp;pw={startPage?}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LongName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Example.com Web Search<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LongName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;64&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;64&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/png&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>http://example.com/websearch.png<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Image</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;16&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;16&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/vnd.microsoft.icon&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>http://example.com/websearch.ico<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Query</span> <span style="color: #000066;">role</span>=<span style="color: #ff0000;">&quot;example&quot;</span> <span style="color: #000066;">searchTerms</span>=<span style="color: #ff0000;">&quot;cat&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Developer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Example.com Development Team<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Developer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Attribution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     Search data Copyright 2005, Example.com, Inc., All Rights Reserved
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Attribution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SyndicationRight<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>open<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SyndicationRight<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AdultContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AdultContent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Language<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>en-us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Language<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;OutputEncoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UTF-8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/OutputEncoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;InputEncoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UTF-8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/InputEncoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/OpenSearchDescription<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Fore more tips read the Google Chrome <a href="http://gears.google.com/chrome/intl/en/webmasters-faq.html">FAQ for web developers</a> page.</p>
<p>ps. Don&#8217;t use the <a href="http://gears.google.com/chrome/">Google gears Chrome download page</a> which gives a JavaScript error!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">_GU_SetupOneClick <span style="color: #000066; font-weight: bold;">is</span> not defined
<span style="color: #000066;">onload</span><span style="color: #009900;">&#40;</span>load <span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/google-chrome-first-impressions.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript Arguments</title>
		<link>http://www.seifi.org/javascript/javascript-arguments.html</link>
		<comments>http://www.seifi.org/javascript/javascript-arguments.html#comments</comments>
		<pubDate>Tue, 19 Aug 2008 23:16:20 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=673</guid>
		<description><![CDATA[The arguments object in JavaScript is a local variable in any function that provides some nice features we can use in our code. Here is the list of its properties and related properties of the Function object. arguments itself returns an object that looks like an array (but not really an array) of the arguments [...]]]></description>
			<content:encoded><![CDATA[<p>The arguments object in JavaScript is a local variable in any function that provides some nice features we can use in our code. Here is the list of its properties and related properties of the Function object.</p>
<p><code>arguments</code> itself returns an object that looks like an array (but not really an array) of the arguments passed to the function.</p>
<p>Prior to JavaScript 1.4 the <code>Function</code> object also had a similar <code>arguments</code> property, which is now deprecated.</p>
<p>However the Function object comes with a few other useful properties that we can still use to get argument related data.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> callTaker<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span>b<span style="color: #339933;">,</span>c<span style="color: #339933;">,</span>d<span style="color: #339933;">,</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// arguments properties</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">callee</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// Function properties</span>
 console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>callTaker.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>callTaker.<span style="color: #660066;">caller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">caller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">callee</span>.<span style="color: #660066;">caller</span>.<span style="color: #660066;">caller</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>callTaker.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>callTaker.<span style="color: #660066;">constructor</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> callMaker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  callTaker<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foo&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  callMaker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>For demonstration purposes, you can <a href="" onclick="return initDemo();">run the init function</a> above and view the logs in FireBug.</p>
<h3>arguments object and its properties</h3>
<p><code><strong>arguments</strong></code> returns ["foo", "bar", Window, Document]</p>
<p><code><strong>arguments.length</strong></code> returns 4</p>
<blockquote class="note"><p>Note: even though our function has a signature with 5 arguments, length returns only 4 here. This is because the caller sent us only 4 arguments. See below for how we can use Function&#8217;s length property to find the number of expected arguments.</p></blockquote>
<p><code><strong>arguments.callee</strong></code> returns callTaker(a, b, c, d, e)</p>
<blockquote class="note"><p>Note: callee shows us the signature of the currently executing function and is useful when trying to make recursive calls to a function within its own body.</p></blockquote>
<p><code><strong>arguments[1]</strong></code> returns bar</p>
<blockquote class="note"><p>Note: arguments can also be set for functions in an array like format. For example you can set the second argument like this: <code><strong>arguments[1] = 'moo';</strong></code>
</p></blockquote>
<h3>Function object and its argument related properties</h3>
<p><code><strong>callTaker.length</strong></code> returns 5</p>
<blockquote class="note"><p>Note: This is the expected number of arguments.</p></blockquote>
<p><code><strong>callTaker.caller</strong></code> is the same as <code><strong>arguments.callee.caller</strong></code> and returns callMaker()</p>
<blockquote class="note"><p>Note: we can go up the stack trace and get the caller of the caller etc. For example we can find the function that called callMaker using <code>arguments.callee.caller.caller</code> which returns init().</p></blockquote>
<p><code><strong>callTaker.name</strong></code> returns callTaker</p>
<p><code><strong>callTaker.constructor</strong></code> returns Function()</p>
<blockquote class="note"><p>Note: Since we have not modified the basic behavior, we see the built in function that creates an object&#8217;s prototype for our function, which is the Function object.
</p></blockquote>
<h3>Basic Usage Sample</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> dataArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;One&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Two&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Three&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Four&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> lister <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> createList<span style="color: #009900;">&#40;</span>list<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span> <span style="color: #339933;">+</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   result <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;li&gt;&quot;</span> <span style="color: #339933;">+</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  result <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;/&quot;</span> <span style="color: #339933;">+</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;l&gt;&quot;</span><span style="color: #339933;">;</span>
  document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> result<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> makeList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 lister<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;list_HTML&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #339933;">,</span>dataArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="" onclick="return makeListDemo();">Run the sample</a><br />
<span id="list_HTML"></span></p>
<p>References:<br />
<a href="http://eriwen.com/javascript/js-stack-trace/" target="_blank">JavaScript Stack Trace</a><br />
<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function" target="_blank">Function</a><br />
<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions:arguments" target="_blank">arguments</a></p>
<style>code strong{color:#F24C8B;font-family:verdana;font-weight:normal;}blockquote.note{margin:0 0 10px;}</style>
<p><script src="http://www.seifi.org/wp-content/uploads/2008/08/arguments.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/javascript-arguments.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Whats new in Safari 3.1 Web Inspector and Snippet Editor</title>
		<link>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html</link>
		<comments>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html#comments</comments>
		<pubDate>Fri, 21 Mar 2008 23:10:03 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.seifi.org/testing/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html</guid>
		<description><![CDATA[Safari 3.1 features improvements to the functionality for the Web Inspector developers tool. In now has an improved console for working with JavaScript and DOM, DOM inspector with CSS support, a nice Network analysis tool and search all built in. It is somewhat comparable to the FireBug plugin for FireFox so I will also make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seifi.org/browsers/safari-31-features.html">Safari 3.1 features improvements</a> to the functionality for the Web Inspector developers tool. In now has an improved console for working with JavaScript and DOM, DOM inspector with CSS support, a nice Network analysis tool and search all built in. It is somewhat comparable to the <a href="http://www.seifi.org/firebug/firebug_tips_and_tricks.html">FireBug plugin for FireFox</a> so I will also make some comparisons of their features.<br />
<span id="more-636"></span></p>
<h3>Web Inspector Overview</h3>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/web_inspector_nav.gif' alt='Web Inspector Navigation' align="right" hspace="10" /> To get started open Web Inspector by going to Safari 3.1/Develop/Show Web Inspector and you will see the new window open up. The initial window is split up into a top row with navigation buttons and search box. The navigation buttons take you the the next and last actions you make within Web Inspector and come in handy when debugging. The left navigation lets you view and inspect the loaded web resources including Documents, StyleSheets, Images, Scripts, WebFonts, Databases and Other files, as well as buttons to load the Console and Network details. Ajax request and responses show up under the Other file category. If any errors are found, the number of errors are placed on the file name in the navigator. For example here, Safari has found 1 bug in the file diggthis.js The main content area shows you the web source details for viewing. JavaScript errors are marked with an orange pop, while HTML and CSS errors have a red color. If you want to attach Web Inspector to the bottom of your Safari Window click the small box on the bottom left corner of the window. I found this this to be a more usable placement.</p>
<h3>DOM Editing</h3>
<p>Clicking on any HTML Document on the left loads the source on the right. Documents can also be viewed as a DOM resrouce by clicking ont he DOM button on the top nav. (Note you have flip between DOM and Source view for HTML files.)</p>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/webinspector_dom_search.gif' alt='DOM Editing' align="right" hspace="10" /> Searching supports DOM and CSS elements and you can nest your DOM element searches to filter out exactly what you&#8217;re looking for. For example #page a returns all anchor tags in the div with the page id. The corresponding display element in Safari is highlighted as you select DOM elements.</p>
<p>The right pane displays Styles, Metrics and Properties for seleted DOM elements. Styles show you both the computed style as well as all the defined style rules for that object. Like FireBug you can edit your CSS rules in real time in the Styles boxes for each CSS rule. To edit any CSS property double click the name or value and an edit box opens allowing you to type in your changes. This is great for testing out new ideas on the fly.</p>
<p>The metrics pane shows you the layout rules including offset, margin, border, padding, width and height for the element. Finally the Properties pane lists all of the DOM object properties that apply to the selected element.</p>
<h3>Downloadable Web Fonts</h3>
<p>If you are using downloadable web fonts the Fonts file group shows you a rendering of all the fonts that are loaded into the user&#8217;s browser.<img src='http://www.seifi.org/wp-content/uploads/2008/03/webfonts.gif' alt='Downloadble Web Fonts' /></p>
<h3>Client Side Databases</h3>
<p>Also if you are using the client side database features of HTML5, the Databases category will let your explore the databases loaded in the client along with the all the tables and rows in each client side database. From here you can also execute SQL queries against the databases.<img src='http://www.seifi.org/wp-content/uploads/2008/03/databases.gif' alt='Client Side Databases' /></p>
<h3>The Console</h3>
<p>The console feature lets you type in JavaScript commands and view JavaScript errors, along with HTML and CSS rule errors. Clicking on any error jumps to the file, but unfortunately doesn&#8217;t go the corresponding line. The console has an input area for testing out JavaScript and DOM commands on the bottom. There is in fact a console object and my tests showed that Safari supports only a few of the <a href="http://www.getfirebug.com/console.html" target="_blank">functions</a> for the console object. Here is a list of the FireBug console methods of which only a few are supported in Safari namely log, info, warn and error.</p>
<blockquote><p>
<strong>Supported methods:</strong><br />
log info warn error<br />
<strong>Unsupported methods:</strong><br />
debug assert dir dirxml trace group groupEnd time timeEnd profile profileEnd count
</p></blockquote>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/console.gif' alt='Safari Console' /></p>
<h3>Network</h3>
<p>The network tab is actually quite nicely designed and show you what the transfer time or the transfer size for each resource and in total for the page. The capsule graph is color coded and breaks down the file types by Docs, CSS, Images, Script and Other. You can switch between time or size from the drop down. Web Inspector makes some suggestions as well for improving speed, for example here we see a recommendation to use file compression to save bandwidth. (I don&#8217;t really use this method now since IE6 is buggy with gzip deflation.) Click on any file to see the HTTP request and response header for that file.<br />
<img src='http://www.seifi.org/wp-content/uploads/2008/03/network.gif' alt='Network tool in Safari' /></p>
<h3>Snippet Editor</h3>
<p>The Snippet Editor is a little utility that allows you to enter blocks of HTML and CSS and have it rendered on the fly. It is quite useful for testing out your CSS and Layout in little chunks.<br />
<img src='http://www.seifi.org/wp-content/uploads/2008/03/snippet_editor.png' alt='Snippet Editor' /></p>
<p>Note: While using the Web Inspector and Snippet Editor, I came across numerous little annoying bugs and usability issues here and there. Also lots of features that I would expect are not there. For example you can not click on elements to inspect them, you can not add new style rules if they don&#8217;t exist already, and you can&#8217;t edit rules for CSS files loaded using @import. I would have to say that <a href="http://www.seifi.org/firebug/firebug_tips_and_tricks.html">FireBug</a> is a superior tool at this time for professional debugging, but Safari is about half way there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Safari 3.1 Features Review</title>
		<link>http://www.seifi.org/css/safari-31-features.html</link>
		<comments>http://www.seifi.org/css/safari-31-features.html#comments</comments>
		<pubDate>Wed, 19 Mar 2008 20:47:40 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.seifi.org/browsers/safari-31-features.html</guid>
		<description><![CDATA[Apple released Safari 3.1 (525.13) for both Mac and Windows users today which comes with a bunch of changes and improvements over 3.0.x series. Here are the set of changes included in the new release. Developer Menu The first thing you will notice is the addition of the &#8220;Develop&#8221; menu (Preferences/Advanced/Show Develop menu in menu [...]]]></description>
			<content:encoded><![CDATA[<p>Apple released <a href="http://www.apple.com/safari/" target="_blank">Safari 3.1</a> (525.13) for both Mac and Windows users today which comes with a bunch of changes and <a href="http://docs.info.apple.com/article.html?artnum=307467" target="_blank">improvements</a> over 3.0.x series. Here are the set of changes included in the new release.</p>
<h3>Developer Menu</h3>
<p>The first thing you will notice is the addition of the &#8220;<strong>Develop</strong>&#8221; menu (Preferences/Advanced/Show Develop menu in menu bar) item with the following tasks:<br />
<span id="more-630"></span><br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/safari_develop_menu.png" title="Safari Developer Menu" alt="Safari Developer Menu" align="right" hspace="15" vspace="5" /> Open Page with: (Other browsers installed on your system including FireFox, Internet Explorer, Opera)</p>
<p>User Agent: Set you user agent from the list of options, or enter your own user-agent. Finally! This was previously part of the hidden debug menu and you had no way of specifying a custom user-agent. The other exciting additions here are the ability to set your user-agent as Mobile Safari 1.1.3 for either iPhone or the iPod touch.</p>
<p>You can also pull up the Web Inspector, Error console, Network Timeline and a Snippet Editor. Lastly the Developer menu allows you to disable various browser features such as Caches, Images, CSS Styles, JavaScript, Runaway JavaScript Timers, and Site-Specific Hacks. You can now also edit CSS in the Web Inspector. More on these in a <a href="http://www.seifi.org/testing/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html">later post</a>.</p>
<h3>Standards Support</h3>
<p>Support for <a href="http://www.w3.org/TR/css3-webfonts/" target="_blank">CSS 3 web fonts</a> using CSS @font-face rules. check out <a href="http://www.alistapart.com/articles/cssatten" target="_blank">what can be done</a> with downloadable fonts in these working samples <a href="http://www.alistapart.com/d/cssatten/heid.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/poen.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/nels.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/stef.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/blok.html" target="_blank">here</a>, and <a href="http://www.alistapart.com/d/cssatten/drim.html" target="_blank">here</a>. The CSS and a sample web font are show below. If you are using Safari 3.1 you should see a cool font.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;Acorn Initials&quot;</span><span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>http<span style="color: #00AA00;">:</span>//www<span style="color: #6666ff;">.domain</span>.com/Acorn___.ttf<span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;truetype&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<style type="text/css" media="all">
@import "/wp-content/uploads/2008/03/webfonts.css";
</style>
<h1 id="webfonts">Safari 3.1</h1>
<p>Support for CSS <a href="http://webkit.org/blog/130/css-transforms/" target="_blank">transforms</a> and <a href="http://webkit.org/blog/138/css-animation/" target="_blank">transitions</a>. Below are some demos of these.</p>
<div style="width:85%;margin:0 auto 10px auto;padding:8px;">
<img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="-webkit-transition:-webkit-transform 1.5s ease-in;" onclick="this.style.webkitTransform='rotate(1440deg)';" /> Here is a sample of the -webkit transform CSS which is now supported by Safari 3.1. Click on the Safari logo to rotate it 1440 degrees.<br />
<br style="clear:both" /></p>
<p><img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="-webkit-transform: skew(35deg, 0deg);" /> The following Safari logo is skewed 35 degrees using -webkit-transform: skew(45deg, 0deg).<br />
<br style="clear:both" /></p>
<p><img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="" onmouseover="this.style.webkitTransform='scale(1.3)'" onmouseout="this.style.webkitTransform='scale(1)'" /> The following image changes its scale using -webkit transform:scale() to zoom in 30% when you mouse over it.<br />
<br style="clear:both" />
</div>
<p>Support for <a href="http://www.whatwg.org/specs/web-apps/current-work/" target="_blank">HTML 5</a> &lt;<a href="http://www.whatwg.org/specs/web-apps/current-work/#video" target="_blank">video</a>&gt; and &lt;<a href="http://www.whatwg.org/specs/web-apps/current-work/#audio" target="_blank">audio</a>&gt; elements. Watch out Adobe and Flash. Here is a <a href="http://webkit.org/blog/140/html5-media-support/" target="_blank">demo</a> of the video tag. There is also added support for SVG images in &lt;img&gt; elements and CSS images and SVG advanced text.</li>
<p>Support for <a href="http://www.whatwg.org/specs/web-apps/current-work/#offline" target="_blank">offline</a> storage for Web applications in <a href="http://www.whatwg.org/specs/web-apps/current-work/#sql" target="_blank">SQL databases</a>. That means you can now store your databases locally on the client&#8217;s machine. Here&#8217;s some sample JavaScript to do the client side databases. Check out <a href="http://webkit.org/misc/DatabaseExample.html" target="_blank">this demo</a> that shows you how it works.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">database.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT * FROM test&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">// do something with the results</span>
   database.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;DROP TABLE test&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// do some more stuff</span>
     <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;My second database query finished executing!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;<br />
Running the <a href="http://www.css3.info/selectors-test/" target="_blank">CSS3 Selector tests</a> reveals that Safari 3.1 has full support for CSS3 Selectors while FireFox 2 and IE 7 are still playing catch up.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/css3_support.png" alt="JavaScript Test Results" /></p>
<h3>Performance Improvements</h3>
<p>Apple claims that Safari 3.1 &#8220;executes JavaScript up to 6 times faster than Internet Explorer 7 and up to 4 times faster than Firefox 2&#8243;. Performance measured in seconds. Testing conducted by Apple in March 2008 on a 2.4GHz Intel Core 2 Duo-based iMac system running Windows XP Professional SP2, configured with 1GB of RAM and an ATI Radeon HD 2600 with 256MB of VRAM. HTML and JavaScript benchmarks based on VeriTest’s iBench Version 5.0 using default settings. Testing conducted with a beta version of Safari; all other browsers were shipping versions. Performance will vary based on system configuration, network connection, and other factors.&#8221; I tested IE7, FF2, and Safari 3.1 with 3 JavaScript performance testers and the Acid 3 test kit. The tools used are<br />
1. <a href="http://acid3.acidtests.org/" target="_blank">Acid3</a> tests.<br />
2. <a href="http://www.jorendorff.com/articles/javascript/speed-test.html" target="_blank">JavaScript speed test</a> written by Jason Orendorff<br />
3. <a href="http://webkit.org/perf/sunspider-0.9/sunspider.html" target="_blank">SunSpider</a> test kit from WebKit.org<br />
4. <a href="http://mootools.net/slickspeed/" target="_blank">slickspeed</a> test from Mootools.net</p>
<p>Here are the results in milliseconds from the tests which seem to agree with the results found by Apple. You can see that Safari 3.1 does in fact have a much more efficient JavaScript processing engine, and is three quarters of the way there when comes to passing the Acid3 tests.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/js_test_results.png" alt="JavaScript Test Results" /><br />
<small>Detail links at SunSpider: &nbsp; <a target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B581,511,611,531,541%5D,%223d-morph%22:%5B561,591,591,631,611%5D,%223d-raytrace%22:%5B701,691,701,711,711%5D,%22access-binary-trees%22:%5B691,701,701,590,701%5D,%22access-fannkuch%22:%5B1132,1122,1102,1072,1362%5D,%22access-nbody%22:%5B570,561,550,550,1071%5D,%22access-nsieve%22:%5B571,571,571,571,1082%5D,%22bitops-3bit-bits-in-byte%22:%5B561,560,561,561,1152%5D,%22bitops-bits-in-byte%22:%5B621,621,621,631,1212%5D,%22bitops-bitwise-and%22:%5B731,731,741,731,852%5D,%22bitops-nsieve-bits%22:%5B581,581,581,581,621%5D,%22controlflow-recursive%22:%5B701,711,712,711,721%5D,%22crypto-aes%22:%5B561,571,561,561,571%5D,%22crypto-md5%22:%5B521,521,531,521,510%5D,%22crypto-sha1%22:%5B460,560,480,460,571%5D,%22date-format-tofte%22:%5B681,631,571,571,611%5D,%22date-format-xparb%22:%5B671,641,611,611,621%5D,%22math-cordic%22:%5B711,701,701,681,701%5D,%22math-partial-sums%22:%5B481,481,471,471,471%5D,%22math-spectral-norm%22:%5B541,521,530,530,530%5D,%22regexp-dna%22:%5B531,530,551,541,551%5D,%22string-base64%22:%5B19198,19338,19007,24445,32326%5D,%22string-fasta%22:%5B641,671,731,761,1312%5D,%22string-tagcloud%22:%5B3605,3705,3576,7872,3635%5D,%22string-unpack-code%22:%5B651,651,701,651,731%5D,%22string-validate-input%22:%5B10765,10736,10526,15542,21941%5D%7D">IE7</a> &nbsp;  &nbsp; <a  target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B1342,1211,1192,1201,1212%5D,%223d-morph%22:%5B1742,1743,1762,1702,1733%5D,%223d-raytrace%22:%5B591,591,621,571,581%5D,%22access-binary-trees%22:%5B350,571,650,681,751%5D,%22access-fannkuch%22:%5B701,681,621,610,611%5D,%22access-nbody%22:%5B1442,1442,1412,1412,1412%5D,%22access-nsieve%22:%5B360,331,340,381,370%5D,%22bitops-3bit-bits-in-byte%22:%5B481,451,471,481,481%5D,%22bitops-bits-in-byte%22:%5B461,460,461,460,451%5D,%22bitops-bitwise-and%22:%5B3555,3565,3525,3455,4536%5D,%22bitops-nsieve-bits%22:%5B581,611,600,581,1152%5D,%22controlflow-recursive%22:%5B201,190,301,250,540%5D,%22crypto-aes%22:%5B531,511,511,501,681%5D,%22crypto-md5%22:%5B381,411,461,411,831%5D,%22crypto-sha1%22:%5B581,510,541,520,571%5D,%22date-format-tofte%22:%5B1402,1212,1042,1042,1121%5D,%22date-format-xparb%22:%5B2243,2123,2193,2053,2093%5D,%22math-cordic%22:%5B1272,1091,1192,1152,1221%5D,%22math-partial-sums%22:%5B842,841,821,841,821%5D,%22math-spectral-norm%22:%5B601,561,540,541,571%5D,%22regexp-dna%22:%5B1062,1161,1142,1141,1132%5D,%22string-base64%22:%5B1092,1092,1081,1092,1072%5D,%22string-fasta%22:%5B921,831,841,842,871%5D,%22string-tagcloud%22:%5B791,681,681,721,761%5D,%22string-unpack-code%22:%5B1111,1082,1132,1192,1072%5D,%22string-validate-input%22:%5B621,641,631,651,661%5D%7D">FireFox 2.2</a> &nbsp;  &nbsp; <a  target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B250,300,280,281,171%5D,%223d-morph%22:%5B170,291,291,271,331%5D,%223d-raytrace%22:%5B321,271,271,271,290%5D,%22access-binary-trees%22:%5B211,191,180,190,210%5D,%22access-fannkuch%22:%5B511,451,490,500,501%5D,%22access-nbody%22:%5B280,280,311,321,291%5D,%22access-nsieve%22:%5B180,90,221,221,231%5D,%22bitops-3bit-bits-in-byte%22:%5B221,220,211,211,80%5D,%22bitops-bits-in-byte%22:%5B140,120,121,131,311%5D,%22bitops-bitwise-and%22:%5B361,390,381,381,370%5D,%22bitops-nsieve-bits%22:%5B241,251,250,250,240%5D,%22controlflow-recursive%22:%5B191,251,240,240,240%5D,%22crypto-aes%22:%5B221,251,250,250,250%5D,%22crypto-md5%22:%5B231,240,240,150,251%5D,%22crypto-sha1%22:%5B250,90,250,210,100%5D,%22date-format-tofte%22:%5B350,350,291,301,331%5D,%22date-format-xparb%22:%5B370,370,431,381,381%5D,%22math-cordic%22:%5B391,411,310,420,410%5D,%22math-partial-sums%22:%5B330,341,421,320,311%5D,%22math-spectral-norm%22:%5B280,280,201,291,201%5D,%22regexp-dna%22:%5B491,491,550,480,441%5D,%22string-base64%22:%5B240,241,261,230,220%5D,%22string-fasta%22:%5B360,350,371,331,330%5D,%22string-tagcloud%22:%5B271,251,251,270,281%5D,%22string-unpack-code%22:%5B270,350,350,280,280%5D,%22string-validate-input%22:%5B210,330,340,291,290%5D%7D">Safari 3.1</a></small></p>
<h3>Microsoft Windows</h3>
<ul>
<li>Improves Back/Forward performance</li>
<li>Supports signed Java applets</li>
<li>Shows Caps Lock icon in password fields</li>
<li>Adds support for showModalDialog</li>
<li>Localized in 16 languages</li>
<li>Adds support for International Domain Names</li>
<li>Improves handling of Japanese, Chinese, and Korean text</li>
<li>Contextual menu now allows opening a link in a window or tab</li>
<li>Improves pop-up blocking to work with plug-ins</li>
</ul>
<h3>Other Improvement</h3>
<ul>
<li>Double clicking on the Tab Bar opens new tab</li>
<li>Includes URL metadata when images are dragged or saved from browser</li>
<li>Opens Download and Activity window in current Space</li>
<li>Supports trackpad gestures for back, forward, and magnify on MacBook Air and compatible MacBook Pro computers</li>
<li>Shows Caps Lock icon in password fields</li>
<li><a href="http://docs.info.apple.com/article.html?artnum=307563" target="_blank">13 Security Fixes</a></li>
<li>Increased site compatibility</li>
<li>Improved application stability</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/safari-31-features.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Google Analytics determines Connection Speeds</title>
		<link>http://www.seifi.org/javascript/how-google-analytics-determines-connection-speeds.html</link>
		<comments>http://www.seifi.org/javascript/how-google-analytics-determines-connection-speeds.html#comments</comments>
		<pubDate>Wed, 12 Mar 2008 18:43:55 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.seifi.org/ajax/how-google-analytics-determines-connection-speeds.html</guid>
		<description><![CDATA[Today I was looking for an unobtrusive method of determining a user&#8217;s connection speed using JavaScript. A quick search on Google returned an array of tricks mostly having to do with using Ajax to make a call behind the scenes, and track the payload time for the small file. In most cases people use an [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was looking for an unobtrusive method of determining a user&#8217;s connection speed using JavaScript. A quick <a href="http://www.google.com/search?q=javascript+connection+speed" target="_blank">search</a> on Google returned an array of <a href="http://myspeed.ebiene.de/" target="_blank">tricks</a> mostly having to do with using Ajax to make a call behind the scenes, and track the payload time for the small file. In most cases people use an image with a random variable at the end to avoid caching, like image.jpg?foo=1Rt2X21. This is all good but adds an HTTP connection which could potentially interfere with the user&#8217;s experience, especially if they are already on a slow connection to begin with.<span id="more-627"></span></p>
<p>Then I discovered something interesting in <a href="https://www.google.com/analytics/" target="_blank">Google Analytics</a>.</p>
<p>Google Analytics tracks and stores connection speeds for your visitors as part of the Network Properties category. The data provided includes Connection Speed and this corresponds with Pages per visit, Average time on Site, Percentage of new visits, and the Bounce rate. But how in the world does Google compile this data? It <a href="http://groups.google.com/group/analytics-help-basics/browse_thread/thread/c3c01931dcdcf1d/07a492c88916f80e?lnk=gst&amp;q=speed#07a492c88916f80e" target="_blank">appears</a> that people are <a href="http://informationgift.com/2006/10/analytics_guesses_connection_s.html" target="_blank">guessing</a> that Google uses the visitor&#8217;s IP address or hostname to do a lookup in an IP database or a <a href="http://groups.google.com/group/analytics-help-tracking/browse_thread/thread/9206114c0909379e/078a201bc3e9b566?lnk=gst&amp;q=speed#078a201bc3e9b566" target="_blank">reverse lookup</a>, and then makes a guess based on what ISP that IP address belongs to. But Google also loads a small .gif file with each <a href="http://www.google.com/support/urchin45/bin/answer.py?answer=28307" target="_blank">urchin</a> request. This article explains a little trick for using time stamped image loading and <a href="http://www.die.net/musings/page_load_time/" target="_blank">log analysis</a> which seems related.</p>
<p><img src="http://www.seifi.org/wp-content/uploads/2008/03/analyticsconnectionspeeds.gif" alt="Google Analytics Connection Speeds" /></p>
<p>So if your IP belongs to RoadRunner, then we can assume you are on a cable connection and file you under that category. This can sometimes get somewhat hairy and lead to ambiguity as evidenced by the Unknown category shown in Google Analytics. It is also interesting to note the Unknown category is the single largest category in my case with 36% of the total data collected. What happens if you are on AOL or EarthLink? Will the database contain the accurate information to pinpoint if you are on dial-up or broadband? How often is the database updated with new information? What about edge cases, for example if you work in an office where you have a &#8220;broadband&#8221; connection but share it with a large group of people?</p>
<p>The good news is that with Analytics the work happens without interfering with the user experience and no additional HTTP connections are needed. The bad news is, it is not done in real time. So if you are looking for a real-time test this will not work for you, unless you build your own seriously fast IP database web service that you can use asynchronously. The other option is to use the binary image payload test, but that also makes life hard for your users.</p>
<p>So, If you are looking for general statistics for a webapp over a date range then Google Analytics might be the way to go. Keep in mind you will end up with a chunk of Unknown data. As for making snap decisions, you can sniff user bandwidth while they surf with payload testing. Here is another sample <a href="http://site.aol.com/speed.html" target="_blank">page at AOL</a> where they put up a simple fork page and determine your bandwidth speed using JavaScript image loading and setting a user cookie. I can think of a dozen reasons why this is a bad idea but I won&#8217;t go into that here.</p>
<p><!--Content type: SDKML. Transform: wc2mtps.xslt.-->PS. It is worth mentioning that Internet Explorer supports a built in behavior called clientCaps, which provides information about features supported by Microsoft Internet Explorer, as well as a way for installing browser components on demand. The <a href="http://msdn2.microsoft.com/en-us/library/ms531088(VS.85).aspx" target="_blank">connectionType</a> property of clientCaps returns either <strong>lan</strong>, <strong>modem </strong>or <strong>offline</strong>. Since this only works in IE and doesn&#8217;t offer too much granularity, it might be a good test if you are <em>only trying to test IE users specifically</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/how-google-analytics-determines-connection-speeds.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aspen Simulator &#8211; Simulates iPhone Safari Browser</title>
		<link>http://www.seifi.org/javascript/aspen-simulator-simulates-iphone-safari-browser.html</link>
		<comments>http://www.seifi.org/javascript/aspen-simulator-simulates-iphone-safari-browser.html#comments</comments>
		<pubDate>Tue, 11 Mar 2008 04:52:21 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.seifi.org/iphone/aspen-simulator-simulates-iphone-safari-browser.html</guid>
		<description><![CDATA[The latest release of the iPhone SDK from Apple comes with an array of new Mac utilities for developing iPhone specific software. One of the new tools included with the iPhone SDK beta is the Aspen Simulator. Aspen is an iPhone simulator that developers can test their apps on which emulates all of the the [...]]]></description>
			<content:encoded><![CDATA[<p>The latest <a href="http://www.seifi.org/iphone/thoughts-on-app-store-and-cocoa-touch-for-iphone.html">release</a> of the iPhone SDK from Apple comes with an array of new Mac utilities for developing iPhone specific software. One of the new tools included with the iPhone SDK beta is the Aspen Simulator. Aspen is an iPhone simulator that developers can test their apps on which emulates all of the the features and functionality of the iPhone. For example you can use the mouse to swipe the page up, down, even pinch and more.<span id="more-623"></span>The Aspen Simulator app is located in the folder: <small>/Developer/Platforms/AspenSimulator.platform/Developer/Applications </small><a href="http://www.seifi.org/wp-content/uploads/2008/03/aspen_simulator.png" title="Aspen Simulator" rel="lightbox"><img src="http://www.seifi.org/wp-content/uploads/2008/03/aspen_simulator.thumbnail.png" alt="Aspen Simulator" title="Aspen Simulator" align="left" border="0" hspace="10" vspace="10" /></a>and has a few of the basic iPhone apps including Contacts, Settings, and most importantly mobile Safari. Using mobile Safari is in Aspen Simulator is a nice way to test out your webapps and see how they would look like on the iPhone. The problem I have found so far in this release is that the user-agent of the Safari browser is not set as an iPhone. This is problematic if you are doing some sort of user-agent sniffing using JavaScript in your webapp in order to show the iPhone specifc version of your site. Here is a screenshot of the Safari in Aspen Simulator and the user agent string. I used a basic alert statemnet to get this and the value is:</p>
<blockquote><p>Mozilla/5.0 (Aspen Simulator; U; Aspen 1_2 like Mac OS X; en-us) AppleWebKit/525.7 (KHTML, like Gecko) Version/3.1 Mobile/5A147p Safari/5525.7</p></blockquote>
<p>This means if you load up sites that only look right on the iPhone they won&#8217;t render correctly on the Aspen Simulator. An example of this is the <a href="http://www.appsafari.com/fun/2375/ygo-ajax-flickr/" target="_blank">Yahoo Ajax Flickr</a> website designed specifically for the iPhone. This page renders correctly if you&#8217;re on an iPhone, but will show you the basic mobile version if it doesn&#8217;t see iPhone in your user-Agent. Next version of Aspen will hopefully have an option to easily edit the user agent string of the Safari browser. For reference the mobile Safari app is located in this folder:</p>
<p><small>/Developer/Platforms/AspenSimulator.platform/Developer/SDKs/AspenSimulator1.2.sdk/</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/aspen-simulator-simulates-iphone-safari-browser.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sniff and Disable Firebug Howto (Gmail example)</title>
		<link>http://www.seifi.org/javascript/sniff-and-disable-firebug-howto-gmail-example.html</link>
		<comments>http://www.seifi.org/javascript/sniff-and-disable-firebug-howto-gmail-example.html#comments</comments>
		<pubDate>Wed, 28 Nov 2007 20:02:38 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seifi.org/ajax/sniff-and-disable-firebug-howto-gmail-example.html</guid>
		<description><![CDATA[Here is a simple test to see if users have Firebug installed on their browsers. Obviously this would also weed out non-FireFox users. if &#40;window.console &#38;&#38; window.console.firebug&#41; &#123; alert&#40;&#34;found Firebug&#34;&#41;; &#125;else&#123; alert&#40;&#34;can't find Firebug&#34;&#41;; &#125; Demo: Sniff for FireBug You may have noticed this message in your Gmail homepage recently: The reason for that is [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple test to see if users have <a href="http://www.seifi.org/firebug/firebug_tips_and_tricks.html">Firebug</a> installed on their browsers. Obviously this would also weed out non-FireFox users.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">console</span> <span style="color: #339933;">&amp;&amp;</span> window.<span style="color: #660066;">console</span>.<span style="color: #660066;">firebug</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;found Firebug&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;can't find Firebug&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-608"></span><br />
Demo: <a href="javascript:if(window.console &#038;&#038; window.console.firebug){alert('found Firebug');}else{alert('can\'t find Firebug');}">Sniff for FireBug</a></p>
<p>You may have noticed this message in your Gmail homepage recently:<br />
<img src='http://www.seifi.org/wp-content/uploads/2007/11/gmail_firebug_issue.gif' alt='Gmail Doesn’t Like Firebug' /></p>
<p>The reason for that is Firebug by default logs all XMLHttpRequests made for all the websites you visit. The problem is that the data that is logged never gets disposed of or cleared out.  Therefore, FireFox having to collect and store that information and the memory for Firefox will eventually get large enough that will cause your computer to start using paged cache. This will then make Gmail seem like you are swimming through molasses. Gmail by default seems to make 22 XMLHttpRequests when I load the main page. It then makes a new XMLHttpRequest every 30 seconds, to check for new emails, so in the span of 1 hour you will have 120 new Ajax calls tacked on. This is a nice feature of Gmail which makes life simple for its users (Notice there is no &#8220;Get new mail&#8221; button anywhere). But now every new Ajax call is another 1kb of data which adds to the memory usage and tacks on more CPU and RAM consumed by Firebug.</p>
<p>No need to worry though since, another nice feature of Firebug is that you can disable it on a domain name basis. </p>
<p><img src='http://www.seifi.org/wp-content/uploads/2007/11/disable_gmail_firebug.gif' alt='How to disable Firebug for any domain name ex) mail.google.com' align="left" hspace="10" vspace="3" /> To turn off Firebug for mail.google.com first open Firebug by hitting the green icon or F12. Click on the bug icon in the top left and choose the second option labeled &#8220;Disable Firebug for mail.google.com&#8221;. Now Firebug will be turned off and the green icon will be changed to a silver icon for this domain. You should notice a smoother and faster Gmail experience. You can also turn it back on by clicking on the link &#8220;Enable Firebug for this website&#8221;.</p>
<p><img src='http://www.seifi.org/wp-content/uploads/2007/11/allowedsites.gif' alt='Allowed Sites…' align="right" hspace="10" vspace="3" /> The other and better method of speeding up your Firefox and still keeping Firebug around, is to disable Firebug all together and enable it for specific sites that you are working on. To disable Firebug, again you click on the Bug icon and this time choose the first option &#8220;Disable Firebug&#8221;.<br />
Now visit any site that you would like to use Firebug on and then &#8220;right click&#8221; on the silver icon on the bottom and choose &#8220;Allowed Sites&#8230;&#8221; From here you can add the domain name for any sites you want to override. This makes your life easier and makes general surfing faster in FireFox, yet allows for using the powers of the almighty Firebug when needed.</p>
<p>If your application is similar to Gmail where XMLHttpRequests are called in a loop you may want to use the sniff script to warn users to disable Firebug for your domain as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/sniff-and-disable-firebug-howto-gmail-example.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple AJAX Request and Response JavaScript</title>
		<link>http://www.seifi.org/javascript/simple-ajax-request-response-javascript.html</link>
		<comments>http://www.seifi.org/javascript/simple-ajax-request-response-javascript.html#comments</comments>
		<pubDate>Fri, 27 Jul 2007 02:43:37 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seifi.org/ajax/simple-ajax-request-response-javascript.html</guid>
		<description><![CDATA[Here is the simple form of an AJAX call made to an XML document, parsing through the returned document and and grabbing the a specific node from the DOM. There is a try/catch clause to handle the 4 different sets of XMLHTTP objects for different browsers. The callback function is called once the response is [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the simple form of an AJAX call made to an XML document, parsing through the returned document and and grabbing the a specific node from the DOM. There is a try/catch clause to handle the 4 different sets of XMLHTTP objects for different browsers. The callback function is called once the response is returned as 4+200 and the response is rendered to the user. Below is the JavasScript code snippet. <span id="more-591"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> XMLHttpArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Msxml2.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Msxml2.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> createXMLHTTPObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> xmlhttp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>XMLHttpArray.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
                        xmlhttp <span style="color: #339933;">=</span> XMLHttpArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> xmlhttp<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">////</span>
<span style="color: #003366; font-weight: bold;">function</span> AjaxRequest<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span>callback<span style="color: #339933;">,</span>method<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> req <span style="color: #339933;">=</span> createXMLHTTPObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        req.<span style="color: #660066;">onreadystatechange</span><span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span> <span style="color: #339933;">!=</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req.<span style="color: #000066;">status</span> <span style="color: #339933;">!=</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
                callback<span style="color: #009900;">&#40;</span>req<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        req.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>method<span style="color: #339933;">,</span>url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        req.<span style="color: #660066;">setRequestHeader</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'User-Agent'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'My XMLHTTP Agent'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        req.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">////</span>
<span style="color: #003366; font-weight: bold;">function</span> AjaxResponse<span style="color: #009900;">&#40;</span>req<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> respXML<span style="color: #339933;">=</span>req.<span style="color: #660066;">responseXML</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>respXML<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> respVAL<span style="color: #339933;">=</span>respXML.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'family'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>
.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'result'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;status&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">+=</span> respVAL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">////</span>
<span style="color: #003366; font-weight: bold;">function</span> ClearResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        mdiv<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;status&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        mdiv.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">////</span>
<span style="color: #003366; font-weight: bold;">function</span> MakeRequst<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        AjaxRequest<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ajax.xml&quot;</span><span style="color: #339933;">,</span>AjaxResponse<span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;get&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #006600; font-style: italic;">////</span></pre></div></div>

<p></p>
<p>And our sample XML file looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;family</span> <span style="color: #000066;">result</span>=<span style="color: #ff0000;">&quot;successful ajax request &amp;amp; response!&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parents<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;father</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Mike&quot;</span> <span style="color: #000066;">last</span>=<span style="color: #ff0000;">&quot;Brady&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mother</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Carol&quot;</span> <span style="color: #000066;">last</span>=<span style="color: #ff0000;">&quot;Martin&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/parents<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;children<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sons<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Greg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Peter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Bobby<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/son<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sons<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;daughters<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Marcia<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Jan<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cindy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/daughter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/daughters<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/children<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;maid</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Alice&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/family<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p></p>
<p>Here is a working sample of this code.</p>
<div id="status" style="border:10px solid #eee;background:#ccc;width:300px;padding:10px 5px;margin:5px 0;">
</div>
<p><button onclick="return MakeRequst();">Ajax Request</button> <button onclick="return ClearResponse();">Reset</button><br />
<script type="text/javascript" src="http://www.seifi.org/apps/simpleajax/ajax.js"></script></p>
<p>Some things to note are:</p>
<p>I&#8217;m using a GET here, but yo can easily change that to a POST in the call to AjaxRequest.</p>
<p>The URL passed to AjaxRequest can contain parameters as needed.</p>
<p>You can handle other readyStates(0,1,2,3) and <a href="http://www.w3.org/Protocols/HTTP/HTRESP.html">HTTP status codes</a> as you wish using the onreadystatechange handle. </p>
<p>I am sending null since I am not posting anything back to the server, but you can swap that with your own Post data if you wish. To set that up you have to also add this line of code before you call send to set the proper <a href="http://w3.org/Protocols/HTTP/HTRQ_Headers.html">request headers</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">req.<span style="color: #660066;">setRequestHeader</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Content-type'</span> <span style="color: #339933;">,</span> 
<span style="color: #3366CC;">'application/x-www-form-urlencoded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></p>
<p>The responseXML property is only available when the request is made to an XML document, so If you are using other document types (HTML,Text,CSV,JSON) you will not have access to this property. If you use anything other than XML data you will have access to the responseText property instead.</p>
<p>Once you have the handle to the responseXML property, you can traverse through the XML DOM like you would with any other DOM object and you can use all the <a href="http://developer.mozilla.org/en/docs/DOM:element">DOM element methods, properties and events</a> that you already know.</p>
<p>For example to get a list of all the sons in the family we can do:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">respSONS<span style="color: #339933;">=</span>respXML.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;son&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
respSonVals <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> x<span style="color: #339933;">&lt;</span>respSONS.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> x<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    respSonVals <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> respSONS<span style="color: #009900;">&#91;</span>x<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">nodeValue</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></p>
<p>Try <a href="" onclick="return getSons()">Get Son Names</a></p>
<div id="domvals" style="border:10px solid #eee;background:#ccc;width:300px;padding:10px 5px;margin-bottom:5px;">Results Go Here:</div>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/javascript/simple-ajax-request-response-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.890 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-03 22:09:17 -->

