<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Dijital Life</title>
	
	<link>http://www.coachwei.com/blog</link>
	<description>Coach Wei' thoughts on dijital life and startups</description>
	<pubDate>Thu, 02 Jul 2009 23:46:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/DirectFromWeb20" type="application/rss+xml" /><feedburner:emailServiceId>DirectFromWeb20</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Build High Performance Web Apps</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/ar8Mi4bJCUA/build-high-performance-web-apps.html</link>
		<comments>http://www.coachwei.com/blog/2009/07/02/build-high-performance-web-apps.html#comments</comments>
		<pubDate>Thu, 02 Jul 2009 23:37:26 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[cloud]]></category>

		<category><![CDATA[High Performance Web]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=295</guid>
		<description><![CDATA[Below are the slides for a recent techstars session:



It covers some basic stuff for web performance, scalability and availability, such as:

Common architecture pattern for horizontal scalability;
How to do load balancing;
Cost effective load balancing options;
Cloud computing does not solve scalability issue;
how to optimize web performance;

A list of free tools available are also mentioned, such as YSlow, [...]]]></description>
			<content:encoded><![CDATA[<p>Below are the slides for a recent <a href="http://www.techstars.org">techstars</a> session:
</p>
<p><iframe src='http://docs.google.com/EmbedSlideshow?id=acmj49ptxpc7_224fpm3mgh' frameborder='0' width='410' height='342'></iframe></p>
<p>
It covers some basic stuff for web performance, scalability and availability, such as:</p>
<ol>
<li>Common architecture pattern for horizontal scalability;</li>
<li>How to do load balancing;</li>
<li>Cost effective load balancing options;</li>
<li>Cloud computing does not solve scalability issue;</li>
<li>how to optimize web performance;</li>
</ol>
<p>A list of free tools available are also mentioned, such as <a href="http://developer.yahoo.com/yslow/">YSlow</a>, <a href="http://www.rockstarapps.com">RockStar Web Profiler</a> and <a href="http://www.rockstarapps.com">RockStar Optimizer</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2009/07/02/build-high-performance-web-apps.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2009/07/02/build-high-performance-web-apps.html</feedburner:origLink></item>
		<item>
		<title>Cloud Providers and Locations</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/smTDHVhjFjw/where-is-the-cloud.html</link>
		<comments>http://www.coachwei.com/blog/2009/06/06/where-is-the-cloud.html#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:01:48 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[cloud]]></category>

		<category><![CDATA[cloud computing]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=294</guid>
		<description><![CDATA[Below is my list of cloud infrastructure providers and their data center locations (as of May 2009):
Cloud Infrasturcture Providers

US: Amazon EC2, RackSpace, GoGrid, SoftLayer, NewServers, ATT, Verizon, Sun Cloud;
EU: FlexiScale, ElasticHosts, Amazon EC2,  ATT, Verizon;
Asia:  ATT, Verizon(?), RackSpace(?), 21ViaNet&#8217; CloudEx(?);

Further:

RackSpace has data centers in US, Europe (London) and Asia(Hongkong), but does not tell [...]]]></description>
			<content:encoded><![CDATA[<p>Below is my list of cloud infrastructure providers and their data center locations (as of May 2009):</p>
<p><strong>Cloud Infrasturcture Providers</strong></p>
<ol>
<li>US: Amazon EC2, RackSpace, GoGrid, SoftLayer, NewServers, ATT, Verizon, Sun Cloud;</li>
<li>EU: FlexiScale, ElasticHosts, Amazon EC2,  ATT, Verizon;</li>
<li>Asia:  ATT, Verizon(?), RackSpace(?), 21ViaNet&#8217; CloudEx(?);</li>
</ol>
<p>Further:</p>
<ol>
<li>RackSpace has data centers in US, Europe (London) and Asia(Hongkong), but does not tell you which data center(s) offer cloud computing capability. I suspect it is only within 1-2 US data centers now(<i>update: RackSpace supports cloud computing at its Dallas and San Antonio data centers at this moment, according to RackSpace twitter response</i>); </li>
<li>Savvis claims support for cloud computing, but one can not find anything meaningful from their website (the site is almost designed for anti-communications);</li>
<li>Sun Microsystem made a big deal announcing Sun Cloud, in particular, saying that they will provide a storage service(similar to S3) and a compute service (similar to EC2). Is this real? Is it still real after Oracle acquisition?;</li>
<li>Terremark also claims support for cloud computing. Again, their site is fairly non-communicative. I couldn&#8217;t even figure out whether they are offering an infrastructure service or a software product;</li>
<li>Integrated Cloud platform providers such as Google AppEngine etc are excluded from the list</li>
</ol>
<p>.</p>
<p>Where are these &#8220;cloud&#8221; data centers located? Here is what I collected:</p>
<ol>
<li>Amazon EC2: two locations currently (Virginia and London, both are my rough guesses. Let me know if you know!). Questions:
<ul>
<li>3 availability zones in US - are these availability zones in the same data center, or in different cities?</li>
<li>Amazon also has data centers in other cities and countries (such as Hongkong). Will EC2 expand to these places?</li>
</ul>
</li>
<li>RackSpace:<br />
RackSpace has data centers in a few locationis: San Antonio (TX), Dallas(TX), Herndon (VA), London, Slough (UK), and Hongkong. However, I couldn&#8217;t find any information indicating which data center(s) supports cloud computing. Or do they all support cloud server? Does anyone know?</li>
<li>GoGrid: San Francisco</li>
<li>NewServers: Miami</li>
<li>SoftLayer: SoftLayer has data centers in three locations: Seattle, Dallas, and Washington DC.<br />
Though I couldn&#8217;t find any explicit information indicating where cloud computing is supported, I suspect all three support it. BTW, I wish some other providers can learn from SoftLayer in using their websites to communicate necessary information.</li>
<li>ATT: ATT Synaptic Hosting has 5 locations: Piscataway, New Jersey; San Diego, California; Annapolis, Maryland; Amsterdam in the Netherlands; Singapore. It seems that all these five support elastic cloud hosting on a  pay-as-you-go model. A huge drawback seems to be the lack of API support. Or at least I couldn&#8217;t find any information from their website. On the other side,  ATT has a total of 38 data centers around the world (including Shanghai, Beijing, Guangzhou). Would ATT provide cloud computing support in some of the other data centers?</li>
<li>Verizon: Verizon announced CaaS(http://www.verizonbusiness.com/us/products/itsolutions/caas/) in early 2009. It looks good on parper, but there are very few little details available from their website. Here are some of the questions: Is there API available? Where are the CaaS data centers? What is the pricing structure? </li>
<li>Savvis: Savvis has data centers in a good list of locations in US (SFO, Chicago, Boston, &#8230;), UK (3), Tokyo, and Singapore. But I have no idea of which cloud computing support is and where they are support from Savvis web site. Any cloud API support?</li>
</ol>
<p>Then in Europe, here are the options:</p>
<ol>
<li>Amazon: UK</li>
<li>RackSpace: UK (2)</li>
<li>FlexiScale: UK (API is available at https://api.flexiscale.com/current/doc/)</li>
<li>ATT(?), Savvis (?) - not quite sure etc.</li>
</ol>
<p>In Asia, options are much more limited. Here they are:</p>
<ol>
<li>ATT: Hongkong, Singapore, Tokyo</li>
<li>Amazon: Hongkong(?) - Amazon does not offer EC2 at HongKong now. Will Amazon do so in the future? Similarly, will ATT offer cloud computing support in Shanghai data center? Will RackSpace offer such in their Hongkong data center?</li>
<li>Finally, 21ViaNet: this is  Chinese hosting company. It announced something called &#8220;CloudEx&#8221; a few months ago and sounds similar to EC2.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2009/06/06/where-is-the-cloud.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2009/06/06/where-is-the-cloud.html</feedburner:origLink></item>
		<item>
		<title>Web Profiler Got Acquired</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/bUMKrGt5J0k/web-profiler-got-acquired.html</link>
		<comments>http://www.coachwei.com/blog/2009/04/01/web-profiler-got-acquired.html#comments</comments>
		<pubDate>Wed, 01 Apr 2009 04:28:59 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[Main Page]]></category>

		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[startup]]></category>

		<category><![CDATA[web 2.0]]></category>

		<category><![CDATA[razor web profiler]]></category>

		<category><![CDATA[rockstarapps]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=292</guid>
		<description><![CDATA[Some of the folks may know that I wrote some code last year (when I was really bored). One of them is called &#8220;Web Profiler&#8221;, a 3-D web profiling tool that produces deep information about web performance.


Part of the inspiration of Web Profiler is due to my years of work related to Ajax and web [...]]]></description>
			<content:encoded><![CDATA[<p>Some of the folks may know that I wrote some code last year (when I was really bored). One of them is called <a href="http://www.razorspeed.com">&#8220;Web Profiler&#8221;</a>, a 3-D web profiling tool that produces deep information about web performance.
</p>
<p>
Part of the inspiration of Web Profiler is due to my years of work related to Ajax and web 2.0. Starting from many years ago when I wrote an Ajax-based world processor to my Rich Internet Application tenure, I always loved what Ajax can do for my web apps, but I was also always intrigued by its performance implications.
</p>
<p>
Further, every time when I look at web performance, I got puzzled and mad. The tools, technology and offering people use today to gauge web performance are essentially what they were 10 years ago, despite that the web has changed so much.  From big vendors to small shops, most web performance tools and techniques only give you a one-dimensional look. For example, most tools only tell you the network performance (request time, response time, etc). A few tools will tell you server processing time.
</p>
<p>The reality is that web performance is 3-dimensional. Client side performance, server side performance and network performance are three inter-related dimensions that you must look at them together in order to understand web performance. </p>
<p><p>To make myself less made, I wrote Web Profiler - it measures server side, network and client side performance of any web application and present them together in a correlated way. For example, if your page loading is slow, Web Profiler can tell you the percent of time spent on client side processing, and network processing. You can look at the chart and see, &#8220;oh, yeah, it is this javascript function that is causing a long network delay that is causing the page slowness&#8221;. </p>
<p>Web Profiler was out in alpha and beta at <a href="http://www.razorspeed.com">RazorSpeed</a> for a few months. It received really good feedback and strong interest from a variety of users. The alpha and beta code were downloaded over 10,000 times over a couple of months. A few hundred users actively used it to do something real(according to the log). A couple of dozens of users asked me about the pricing model and how they can pay something. A few users offered to pay something outright and I politely declined their offers. </p>
<p>Just when I was trying to figure out what to do with the momentum, I was approached by a couple of interested parties that see the potential of a new generation of service for web 2.0 applications. After quite a few conversations, some alcohol and a bunch of paperwork, I am happy to announce that Web Profiler has been acquired by RockStar.</p>
<p><a href="http://www.rockstarapps.com">RockStar</a> is a premium brand in web performance. I met the folks there a few times and I have been truly impressed by their vision, capability to execute and market traction. It is a match made in heaven, and I strongly believe Web Profiler will achieve its full potential as part of the RockStar offerings going forward. </p>
<p>Unfortunately lawyers advised me not to disclose the acquisition price. Though I can say that I am very happy with the transaction. The deal is done so that I can finally say what I thought when they first told me the number they were thinking about: it is an insane amount of money (I know RockStar folks knew my thought on the number,  but they believe it is worthwhile). </p>
<p>What&#8217;s next? I want to assure Web Profiler users that I will continue to help the product out. You can still email me bugs and complains. The folks at RockStar are going to be super helpful too. </p>
<p>Beyond that, given that I&#8217;ve already taken a few days off and had a few celebration drinks already, I&#8217;d better just go right back to work.  So the next stop for me is <a href="http://www.yottaa.com">yottaa</a>. We&#8217;ll see where it leads us&#8230;Until then, happy finger workout! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2009/04/01/web-profiler-got-acquired.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2009/04/01/web-profiler-got-acquired.html</feedburner:origLink></item>
		<item>
		<title>Starting a company during a down economy</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/G3kSQPBD-GM/starting-a-company-during-a-down-economy.html</link>
		<comments>http://www.coachwei.com/blog/2009/03/16/starting-a-company-during-a-down-economy.html#comments</comments>
		<pubDate>Mon, 16 Mar 2009 18:24:52 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=291</guid>
		<description><![CDATA[Not sure whether this is lucky or unlucky, I am probably wedded to the pattern of &#8220;starting a company during a down economy&#8221;.  For comrades who are starting a company during the current couple of years, you are probably wedded to the same pattern too. 
To me, the root trigger of &#8220;falling&#8221; into this [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure whether this is lucky or unlucky, I am probably wedded to the pattern of &#8220;starting a company during a down economy&#8221;.  For comrades who are starting a company during the current couple of years, you are probably wedded to the same pattern too. </p>
<p>To me, the root trigger of &#8220;falling&#8221; into this pattern is that I started <a href="http://www.nexaweb.com">Nexaweb</a> right after the dot com burst and raised Series A in 2003, the year of the lowest venture capital investment over the last 15 years. After a few more years of growing Nexaweb and finally getting ready to start something new, the economy also went through its own cycle. So here I am, trying to start a <a href="http://www.yottaa.com">company</a>  during a down economy again.  What&#8217;s next? It is highly likely that the time when I start yet another company in the future will coincide with a similar moment in yet another economic cycle and so on. </p>
<p>Gee. I should have read <a href="http://www.coachwei.com/blog/2009/03/16/starting-a-company-during-a-down-economy.html">this blog piece</a> when I was young,  and launched Nexaweb either a few years earlier or a few years later. </p>
<p>The reality is that entrepreneurs don&#8217;t have too much control on such things. Entrepreneurship is about seeing an opportunity, believing in the opportunity and taking actions on the opportunity. Opportunities come and go independent of the economy or anything else.  If you see it and believe it, the entrepreneurial spirit inside doesn&#8217;t give one too much choice but to do something about it.  In some sense, starting a company is like having a baby: you can rationalize, plan and time it all you want beforehand. However, once the triggered is pulled,  the baby comes at the time designated by the almighty regardless of the state of the economy, one&#8217;s wishes/desires or anything else.  </p>
<p>The other side of the reality is that it is not that bad to start a company in a bad economy. Some say it is tough to start something new when everyone else is hiding under their desks. Certainly true. Some other people would say it is actually good to start something now given the abundance of talents and etc. I can argue either way. Frankly, I don&#8217;t think it matters that much either way. Regardless of the timings, it is about being &#8220;relentless resourceful&#8221; (citing <a href="http://www.paulgraham.com/relres.html">Paul Graham</a>) in a way that is fairly similar to long distance running to me. </p>
<p>For comrades who are in the middle of starting up something now, here is a good diagram to look at (citing from <a href="http://www.feld.com/wp/archives/2009/03/entrepreneurs-dont-be-afraid-of-gdp-growth-rate.html">Brad Feld</a>). It shows some empirical data between the timing of economic cycles and good companies founded:</p>
<p><img style="border: 0px;" src="http://www.feld.com/blog/graphics/EntrepreneursDontBeAfraidofGDPGrowthRate_B7DE/gdpgrowth.jpg" border="0" alt="GDP Growth and Company Formation" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2009/03/16/starting-a-company-during-a-down-economy.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2009/03/16/starting-a-company-during-a-down-economy.html</feedburner:origLink></item>
		<item>
		<title>Please, Economic Stimulus Plan - 10,000 Startups with $1B</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/vAnYEtyzDm0/please-economic-stimulus-plan-10000-startups-with-1b.html</link>
		<comments>http://www.coachwei.com/blog/2009/03/07/please-economic-stimulus-plan-10000-startups-with-1b.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 21:23:01 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[Main Page]]></category>

		<category><![CDATA[startup]]></category>

		<category><![CDATA[startups]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=290</guid>
		<description><![CDATA[This is a post echoing what a variety of people have been talking about for the last few weeks - I don&#8217;t have a lot  to contribute, but am compelled and felt worthwhile to echo other people&#8217;s voice here.
On Februrary 21 2009, Thomas Friedman of the New York Times wrote “Startup the Risk Takers” where [...]]]></description>
			<content:encoded><![CDATA[<p>This is a post echoing what a variety of people have been talking about for the last few weeks - I don&#8217;t have a lot  to contribute, but am compelled and felt worthwhile to echo other people&#8217;s voice here.</p>
<p>On Februrary 21 2009, Thomas Friedman of the New York Times wrote “<a style="text-decoration: underline; color: #6699cc;" href="http://www.nytimes.com/2009/02/22/opinion/22friedman.html">Startup the Risk Takers</a>” where he said:</p>
<p><em>“Reading the news that General Motors and Chrysler are now lining up for another $20 billion or so in government aid — on top of the billions they’ve already received or requested — leaves me with the sick feeling that we are subsidizing the losers and for only one reason: because they claim that their funerals would cost more than keeping them on life support. Sorry, friends, but this is not the American way. Bailing out the losers is not how we got rich as a country, and it is not how we’ll get out of this crisis.”</em></p>
<p>Further, Friedman points out that how such bailout money should be spent on: &#8220;<em>imited financing, for a limited time, targeted on an industry bristling with new technology start-ups that, with a little push from Uncle Sam, won’t just survive this crisis but help us thrive when it is over. We need, and the world needs, an America that is thriving not just surviving</em>&#8220;.</p>
<p>While I sort of understand the government using tax payer&#8217;s money to bail out financial institutions because we can not afford the collapse of the financial service industry, I do not see the strategic importance of the auto industry in this day and age. Why not fuel the $20B to new promising areas that would create lots of new jobs and lead to future prosperity?</p>
<p>Interesting, in response to Friedman&#8217;s post,  Fred Wilson of Union Square Ventures says “<a href="http://www.avc.com/a_vc/2009/02/a-stimulus-plan-for-venture-capital-no-thanks.html">No Thanks</a>”. Fred writes “The venture capital business, thankfully, does not need any more capital. It&#8217;s got too much money in it, not too little. Just ask the limited partners who have been overfunding the venture capital business for the past 15-20 years what they think. You don&#8217;t even need to ask them. They are taking money out of the sector because the returns have been weak.”</p>
<p>I appreciate Fred&#8217;s point of view from a VC&#8217;s perspective and would agree that giving $1B to the top 20 venture capital firms is not a good idea either (as suggested by Friedman&#8217;s original article), I think Friedman&#8217;s main point is valid: send money to those who create our future, not to bail out &#8220;giant wealth-destruction machine in history&#8221;.</p>
<p>As an entrepreneur, I certainly see Fred&#8217;s point that there are too much VC captial. But on the other side, I aslo see lots of startup companies that, with a little bit more money, can survive and thrive. I have seen various startups being caught in this economic situation, not because these companies are weak, but because of the ripple effect: limited partners in VC firms are getting burned; VCs are re-adjusting to a new reality of &#8220;longer fund cycle&#8221; and &#8220;portofolio companies need more than expected cash to reach exits&#8221;. As a result, VCs are finding <b>their fund is not enough to cover the needs of portfolio companies</b>. VCs are conserving their own fire power on &#8220;only the few highly promising portfolio companies&#8221;.  Some of the VCs even asked money back from their investments so that they can pour some more cash into selected companies.</p>
<p>(Jeff Bussgang has a good post &#8220;<a href="http://bostonvcblog.typepad.com/vc/2008/11/why-flat-is-the-new-up-and-vc-funds-are-underreserved.html">Why &#8220;Flat Is The New Up&#8221; and VC Funds Are Under-Reserved</a>&#8221; that helps one understand why VCs have to conserve cash, and may not be able to continue to fund some existing portfolio companies).</p>
<p>The net result is that a variety of companies, close to profitability or well on the way to profitability, are being caught in the middle. A lot of these companies are good companies - they may not be the next google, but they can certainly create jobs and reach profitability, if they don&#8217;t lose the needed &#8220;little push&#8221; prematurely. In other words, they may not be &#8220;wealth creation tools&#8221; that Fred is talking about in his response, but they are perfect small businesses that the country needs.</p>
<p>Programs like techstars (http://www.techstars.og) and MIT VMS (http://vms.mit.edu) create tomorrow&#8217;s companies with zero or little financial resources. How about dropping a tiny drop of the stimulus fund into similar programs, or other ways to help build, grow and sustain small businesses?<br />
Though there are a lot of VC capital in general, VC capital only flows into these who are likely to become the next Google. That is not to say that these companies who are not going to become Google are not valuable. To the opposite, they are extremely valuable to the society. They can create millions of jobs, help our economic recovery, and most importantly, help secure our future. They may not be the kind of companies that fit the VC model, but our country and our society should certainly welcome them, love to have them, and when they need a little bit push,  please don&#8217;t just walk away from them.</p>
<p>So please, Economic Stimulus Plan,  you can create or boost 10,000 startups with $1B. A lot of them will fail and a lot of them will survive. But none of them is going to be &#8220;giant wealth destruction machine&#8221; and each of them is going to  help build our future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2009/03/07/please-economic-stimulus-plan-10000-startups-with-1b.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2009/03/07/please-economic-stimulus-plan-10000-startups-with-1b.html</feedburner:origLink></item>
		<item>
		<title>HTTPS/SSL Tunneling and Proxy Server</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/vg25lxmjCH8/https-tunneling.html</link>
		<comments>http://www.coachwei.com/blog/2008/11/14/https-tunneling.html#comments</comments>
		<pubDate>Sat, 15 Nov 2008 05:29:55 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[https tunneling]]></category>

		<category><![CDATA[jetty]]></category>

		<category><![CDATA[proxy]]></category>

		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=289</guid>
		<description><![CDATA[HTTPS Tunneling, also called HTTPS Proxy,  SSL proxy, or SSL tunneling, refers to sending HTTPS content via a proxy server.  This is a very common usage scenario over the web. 
Unfortunately, I have not found any Java server that supports this  yet. Tomcat chokes up quickly if you tunnel HTTPS messages (tried [...]]]></description>
			<content:encoded><![CDATA[<p>HTTPS Tunneling, also called HTTPS Proxy,  SSL proxy, or SSL tunneling, refers to sending HTTPS content via a proxy server.  This is a very common usage scenario over the web. </p>
<p>Unfortunately, I have not found any Java server that supports this  yet. Tomcat chokes up quickly if you tunnel HTTPS messages (tried both Tomcat 5.x and 6.x). Other Java servers don&#8217;t even come close. Jetty is the furthest and closest to supporting it.  <a href="http://blogs.webtide.com/gregw/">Greg Wilkins</a> even wrote two  examples showing Jetty&#8217;s proxy support (ProxyServlet and AsyncProxyServlet, though both of them only partially work when I tried to run them on on Jetty 6.x and Jetty 7.x).  </p>
<p>The main problem for all these servers is that they do not support HTTP Connect.  We all know HTTP GET, and HTTP POST, and all servers support these common HTTP methods beautifully, except for HTTP Connect. </p>
<p>The problem with HTTP connect are two folds:<br />
<OL><br />
<LI>Most servers simply fail at even parsing an HTTP connect request, except for Jetty, let alone anything else. </LI><br />
<LI>Jetty can parse HTTP connect request (semi) successfully, but it does not seem to enable any further processing of HTTP connect request (such as reading from the request&#8217;s inputstream);</LI><br />
</OL></p>
<p>Problem No.1 is that HTTP connect request looks very different from other HTTP requests, and most servers do not take HTTP connect requests into consideration. When the browser is initiating an HTTPS connection via a proxy server, the browser will send the following request to a proxy server:</p>
<p><code><br />
CONNECT some.server.com:443 HTTP/1.1<br />
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17<br />
Proxy-Connection: keep-alive<br />
Host: some.server.com<br />
</code></p>
<p>In contrast, a typical HTTP request would look like:</p>
<p><code><br />
GET /a/b/c.html HTTP/1.1<br />
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17<br />
Host: some.server.com<br />
</code></p>
<p>Problem No.2 is that HTTP Connect requires a two-step handling. After sending out this request header, the browser will &#8220;halt&#8221; the request and wait to hear back from the network before sending out any content;</p>
<p>The proxy server should respond to the above request by trying to initiating a connection with the remote server (some.server.com at port 443 in the above example). If a connection is established successfully, the proxy server should respond to the browser by sending back:</p>
<p><code><br />
HTTP/1.1 200 Connection Established<br />
</code></p>
<p>Then proxy server should wait. On the other side, once the browser receives &#8220;200&#8243; status from the server, the browser will now send the actual HTTPS content to the request connection. Once the proxy server receives the content, it should send such content to the remote server. The remote server will then respond and such response needs to be &#8220;copied&#8221; back to the browser, which would appear as part of the &#8220;HTTP/1.1 200 Connection Established&#8221; message shown earlier. </p>
<p>I hope I am missing something here - if you know Jetty server or any other server that works well for HTTPS tunneling, please comment below!</p>
<p>Some useful links for more information on this subject:<br />
<DL><br />
<DT>Tunneling SSL Through a WWW Proxy, http://muffin.doit.org/docs/rfc/tunneling_ssl.html</DT><br />
<DT>Implement HTTPS tunneling with JSSE, http://www.javaworld.com/javaworld/javatips/jw-javatip111.html?page=1</DT><br />
<DT>Jetty bug tracker &#8220;Allow interception of CONNECT method to support proxy impls&#8221;, http://jira.codehaus.org/browse/JETTY-625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel</DT><br />
<DT>Jetty ProxyServlet, http://www.mortbay.org/jetty/jetty-6/apidocs/org/mortbay/servlet/ProxyServlet.html</DT><br />
</DL></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/11/14/https-tunneling.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/11/14/https-tunneling.html</feedburner:origLink></item>
		<item>
		<title>Who Should Be USA’s CTO in the Obama Administration?</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/cQoS75nT-Hc/who-should-be-the-usas-cto-in-the-obama-administration.html</link>
		<comments>http://www.coachwei.com/blog/2008/11/07/who-should-be-the-usas-cto-in-the-obama-administration.html#comments</comments>
		<pubDate>Fri, 07 Nov 2008 19:23:09 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[politics]]></category>

		<category><![CDATA[Obama]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=288</guid>
		<description><![CDATA[Jeremy Geelan is speculating who should be America&#8217;s CTO in the Obama administration. He says:

As former IAC executive Julius Genachowski was appointed yesterday to President Elect Obama&#8217;s transition team, speculation is growing as to the possibility that Genachowski or someone like him may one day soon become the country&#8217;s first Chief Technology Officer. Barack Obama&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Jeremy Geelan is speculating <a href="http://www.sys-con.com/node/739558">who should be America&#8217;s CTO in the Obama administration</a>. He says:<br />
<em><br />
As former IAC executive Julius Genachowski was appointed yesterday to President Elect Obama&#8217;s transition team, speculation is growing as to the possibility that Genachowski or someone like him may one day soon become the country&#8217;s first Chief Technology Officer. Barack Obama&#8217;s transition team also includes Sonal Shah of Google.org and Donald Gips, VP of corporate strategy and development for Level 3 Communications.<br />
</em><br />
Other candidates for the nation&#8217;s CTO position being mooted in the press are: Google&#8217;s CEO Eric Schmidt, Sun co-founder Bill Joy, etc.</p>
<p>First of all, the notion of having a CTO for USA is very exciting. It&#8217;s a job that I&#8217;d really want to have  - I&#8217;m working on my resume right now!!!</p>
<p>More importantly than who will be the CTO is which industry this person should be coming from. I&#8217;d really really recommend the following three industries:</p>
<ol>
<li>Information technology industry</li>
<li>Information technology industry</li>
<li>Information technology industry</li>
</ol>
<p>Not because I&#8217;m from the IT industry, but rather because IT is the industry that the title of CTO is born from  and IT is the industry that is leading the society in terms of not only technical advances, but rather more importantly, culture evolutions.  Biotech and energy industries are all hugely important, and may produce far more important technological breakthroughs than the IT industry would be able to, but IT has become part of our culture (as proven in my blog entry <a href="http://www.coachwei.com/blog/2008/01/08/the-common-culture-root-of-web-20-and-barack-obama.html">The Common Culture Root of Web 2.0 and Barack Obama</a>).</p>
<p>Part of the reason for Obama&#8217;s win is due to his campaigns usage of IT in building out grassroots support and reaching out to millions of people. The web and the internet, did wonders in politics!</p>
<p>Who would I nominate? Given that Jeremy does not allow self-promotion, let me just say that the 2nd best candidates are:</p>
<ol>
<li>Mitt Romney (what? Did i actually type this out?)</li>
<li>Charles Vest (former MIT President. Disqualified because of lacking IT industry background, but a University president may not be a bad idea. Did I effectively nominated Larry Summers here?)</li>
<li>Marc Andreessen</li>
<li>VCs like Vinod Khosla are good choices (as a catogery, VCs are good pools to look into)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/11/07/who-should-be-the-usas-cto-in-the-obama-administration.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/11/07/who-should-be-the-usas-cto-in-the-obama-administration.html</feedburner:origLink></item>
		<item>
		<title>Razor Optimizer, a New Approach for Ajax Optimization</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/mNtGboxQZ4s/razor-optimizer-a-new-approach-for-ajax-optimization.html</link>
		<comments>http://www.coachwei.com/blog/2008/11/05/razor-optimizer-a-new-approach-for-ajax-optimization.html#comments</comments>
		<pubDate>Thu, 06 Nov 2008 03:21:47 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[Main Page]]></category>

		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[Ajax Optimization]]></category>

		<category><![CDATA[Razor Optimizer]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=287</guid>
		<description><![CDATA[I am excited to announce the early beta release of Razor Optimizer, a JavaScript optimization tool for reducing code footprint and increasing runtime performnace. As  a cross-browser web application itself,  Razor Optimizer can be access either online as a service,  or to be downloaded to run locally.


Razor Optimizer is based on a [...]]]></description>
			<content:encoded><![CDATA[<p><P>I am excited to announce the early beta release of <a href="http://www.razorspeed.com/index.php/what-is-it/what-is-razor-optimizer">Razor Optimizer</a>, a JavaScript optimization tool for reducing code footprint and increasing runtime performnace. As  a cross-browser web application itself,  Razor Optimizer can be access either <a href="http://www.razorspeed.com">online as a service</a>,  or to be <a href="http://www.razorspeed.com/index.php/download">downloaded</a> to run locally.
</p>
<p>
Razor Optimizer is based on a new approach for JavaScript optimization called &#8220;razor&#8221;. While other optimization techniques such as JS minimization and concatenttion are based on static lexical analysis, Razor uses dynamic runtime profile information to achieve breakthrough results of 60% to 90% savings.
</p>
<p>
<Strong>Why Razor Optimizer?</Strong>
</p>
<p>
It is safe to say that <a href="http://en.wikipedia.org/wiki/AJAX">Ajax</a> is the technology foundation for Web 2.0.  There are several hundred Ajax toolkits in the marketplace and new ones are still emerging.
</p>
<p>While Ajax is getting real popular over the web, what people may not know is that Ajax(JavaScript) code is becoming the top 1 or 2 factors to consider in terms of footprint and performance impact in relation to the overall site (or application). 40% to 70% of the footprint of today&#8217;s typical web 2.0 sites is JavaScript. For example, the front page of <a href="http://www.facebook.com">FaceBook</a> contains 532KB JavaScript, 77% of the page footprint. Ajax toolkits have also become more sophisticated and bigger.</p>
<p>Developers are aware of the &#8220;code bloat&#8221; issue. Some developers choose to lower footprint by using shorter variable names and more compact code style.  There are various optimization techniques available such as compression,  JS minimization and file concatenation. All these are helpful, but none of them is helpful enough. </p>
<p><p>
What can we do to bring Ajax to its full potential, and empower developers to use Ajax without worries?
</p>
<p>
Note that the problem is not new. Similar challenges exist for other programming languages.  In early 2007, while studying Dojo performance, I <a href="http://www.coachwei.com/blog/2007/04/04/dojo-footprint-and-ajax-performance-recommendation.html">blogged</a> about &#8220;borrowing&#8221; approaches from other languages to optimize Ajax code(see <a href="http://www.coachwei.com/blog/2007/04/04/dojo-footprint-and-ajax-performance-recommendation.html">Dojo Footprint and Ajax Performance Recommendation</a>). At the time, I was hoping someone in the Dojo community would implement this.  In late 2007 or early 2008, I remember seeing some research paper from Microsoft Research talking about something they call &#8220;Donoto&#8221; (unfortunately I couldn&#8217;t find any information about Denoto on the web. If you know it, please post it in comments).
</p>
<p>
Razor Optimizer is based on a new approach coming from such kind of new thinking. Its goal is to free developers from the worries of code bloat, and free users from JavaScript introduced browser freezing.
</p>
<p>In one sentence, Razor Optimizer (hopes to) lights up the web!
<p><br/></p>
<p><Strong>Razor Optimization Features</Strong></p>
<p>
As an Ajax application itself, Razor Optimizer offers the following features:<br />
<UL><br />
<LI>Runs in any browser</LI><br />
<LI>Works with any Ajax application and Ajax toolkit</LI><br />
<LI>A built-in profiler that records and visualizes application runtime profile data;</LI><br />
<LI>Full automated, no programming required</LI><br />
<LI>Detailed result reporting with comparison to other optimization techniques</LI><br />
<LI>Light up your app with 50% to 90% footprint reduction</LI><br />
<LI>Reduce the number of network round trips</LI><br />
</UL>
</p>
<p><br/></p>
<p><Strong>How It Works</Strong></p>
<p>
Razor Optimizer itself is a web based JavaScript application that runs in any browser. It contains a server component and a client component. Razor Optimizer client is an Ajax application based on <a href="http://www.dojotoolkit.org">Dojo 1.1</a>. Razor Optimizer Server is a Java web application that runs inside any Java Servlet container. The following figure shows the architecture of Razor Optimizer.
</p>
<p>
<center><br />
<img src="http://www.razorspeed.com/customfiles/images/razor-optimizer-architecture.png" alt="Razor Optimizer Architecture"></img><br />
<br />
<b>Razor Optimizer Architecture</b><br />
</center>
</p>
<p><br/></p>
<p><Strong>Razor Optimization Case Studies</Strong></p>
<p>
In general, Razor is able to reduce application footprint by 60% to 80%.<br />
The followings present three different application examples. The three applications are:<br />
<OL><br />
<LI>American Airline’s web site (http://www.aa.com): this site uses PrototypeJS JavaScript library, one of the popular Ajax toolkits;</LI><br />
<LI>Razor Optimizer itself: Razor Optimizer is  a Dojo 1.1 based JavaScript application;</LI><br />
<LI>jQueryUI demo (http://ui.jquery.com/functional_demos/): this is an application based on the popular jQuery library. </LI><br />
</OL></p>
<p><center><br />
<b>Table 1: Applications to be Optimized</b></p>
<table border="1">
<tr>
<td></td>
<td>Ajax toolkit</td>
<td>Total JavaScript footprint (byte)</td>
</tr>
<tr>
<td>www.aa.com</td>
<td>Prototype JS</td>
<td>294,124</td>
</tr>
<tr>
<td>Razor Optimizer</td>
<td>Dojo Toolkit</td>
<td>1,158,664</td>
</tr>
<tr>
<td>jQuery UI Demo</td>
<td> jQuery</td>
<td>151,151</td>
</tr>
</table>
<p></center></p>
<p><br/><br />
Table 2 shows optimization results for these three applications. Razor achieved 67%, 75% and 62% savings for them respective.<br />
<br/><br />
<center><br />
<b>Table 2: Razor Optimization Results</b></p>
<table border="1">
<tr>
<td></td>
<td>Original (byte)</td>
<td>Razor Optimized(byte)</td>
<td>Savings</td>
</tr>
<tr>
<td>www.aa.com</td>
<td>294,124</td>
<td>96,735</td>
<td>67%</td>
</tr>
<tr>
<td>Razor Optimizer</td>
<td>1,158,664</td>
<td>292,203</td>
<td>75%</td>
</tr>
<tr>
<td>jQuery UI Demo</td>
<td>151,151</td>
<td> 56,904</td>
<td> 62%</td>
</tr>
</table>
<p></center></p>
<p><br/></p>
<p>
In comparison, Razor delivers significantly better results than other JavaScript optimization techniques. Using ShrinkSafe to optimize these three applications, the results would be 189KB, 568KB, and 86KB respectively (See Table 5). Razor further cuts down these numbers by half.
</p>
<p><br/></p>
<p><Strong>The Idea Behind Razor Optimizer</Strong><br />
Razor is based on the following observations:</p>
<p>
<OL><br />
<LI>JavaScript functions are the basic low level building blocks of JavaScript code. Though typical JavaScript applications are made up of JavaScript files, functions are at a lower level than files because each JavaScript file is composed of JavaScript functions. While current JavaScript optimization techniques operates on a “file” level,  performing optimization at the function level could yield much better result; </LI><br />
<LI>At any moment of time, the browser needs only one function because only one JavaScript function is executed at any moment of time.<br />
</LI><br />
<LI>Theoretically, the application would work fine if we download only one function at a time, right before the function is going to be called. Other functions are not needed. They can stay on the server side without being downloaded until they are going to be called. There is no need to download all the code up front, and there no need to download them at once;</LI><br />
<LI>If only one function needs to be downloaded and stay on the client side, we can achieve breakthrough savings in both download size as well as client memory/CPU footprint, resulting in significant performance improvements above any other techniques.<br />
</LI><br />
</OL></p>
<p>The basic idea of Razor is to “trim” the “not needed” functions and only download these functions that are necessary for a specific usage scenario. This “trimming” process is called “raze”.  After the initial download, if a “razed” function is needed, Razor will download this function on demand in the background.
</p>
<p>
Wouldn&#8217;t downloading one function at a time be very slow? Indeed. However, if you package a bunch of related functions together and if this one &#8220;package&#8221; is enough to fulfill one or more use scenarios, the user wouldn&#8217;t notice any negative performance impact of incremental downloading.
</p>
<p>
So the key to this approach is to understand when/which function is called during different runtime scenarios.  For example, if we know exactly which functions are called and when they are called during the initial application loading, we can trim all other code from the initial download without breaking the application. This would significantly save the initial download size and improve page loading performance.
</p>
<p>
The knowledge of “when/which function is executed” can be achieved by profiling the application. By recording the profile data, we can have accurate knowledge of the dynamic runtime behavior of the application beyond static lexical analysis for delivering breakthrough optimization results.
</p>
<p><Strong>How to Use It</Strong></p>
<p>
After you downloaded and installed Razor Optimizer (see instructions at <a href="http://www.razorspeed.com/download/GettingStartedWithRazor.html">GettingStartedWithRazor.html</a>):<br />
<OL><br />
<LI>Start Razor server;</LI><br />
<LI>Open a browser instance and visit URL http://localhost:9090 to launch Optimizer UI;</LI><br />
<LI>Click &#8220;New Session&#8221; to start a new session. You may need to login. If you don&#8217;t have an account, register one;</LI><br />
<LI>Enter the URL of your application, for example, http://ajaxian.com. This URL must be accessible from the Razor Server instance you are using;</LI><br />
<LI>Razor will attempt to open a new browser window to launch your application. Make sure that you configured your popup blocker to allow it to so do. </LI><br />
<LI>Your application will be running in its own browser window. Just click around your application (try to stay on the same page though, because multi-page scenarios have not been tested enough for Razor Optimizer). </LI><br />
<LI>At the meantime, Razor is recording profile data in the background;</LI><br />
<LI>Click &#8220;Close and View Results&#8221; to finish profiling. </LI><br />
<LI>Click &#8220;Optimize&#8221; to configure optimization. From here, you can configure file concatenation, ordering, function preservation, etc. </LI><br />
<LI>Finally, click &#8220;Optimize it now&#8221; to perform optimization. Razor server will process your code and generate a report in the end that shows you optimization results. You can download the results as a ZIP file;</LI><br />
<LI>Deploy the ZIP file to your application, test it and iterate a few times to achieve optimal outcome;</LI><br />
</OL></p>
<p><center><br />
<img src="http://www.razorspeed.com/customfiles/images/optimizer-concatenation.png" alt="Razor Optimizer Screen Shot"></img><br />
<br />
<b>Razor Optimizer Screen Shot</b><br />
</center></p>
<p>A sample optimization report would look like <a href="http://www.razorspeed.com/customfiles/images/Razor-optimization-report.html">this</a>.
</p>
<p><strong>Try It out</strong></p>
<p>Razor Optimizer <i>early beta</i> is available for <a href="http://www.razorspeed.com/index.php/download">download</a>. Try it out! Please comment below to let us know the problems you run into, complains or suggestions, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/11/05/razor-optimizer-a-new-approach-for-ajax-optimization.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/11/05/razor-optimizer-a-new-approach-for-ajax-optimization.html</feedburner:origLink></item>
		<item>
		<title>JavaScript Optimization Techniques Today</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/gcQwVRIuatI/javascript-optimization-techniques-today.html</link>
		<comments>http://www.coachwei.com/blog/2008/10/27/javascript-optimization-techniques-today.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 10:18:47 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[web 2.0]]></category>

		<category><![CDATA[Ajax Optimization]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=286</guid>
		<description><![CDATA[The wild popularity of Ajax fueled widespread usage of JavaScript.  Almost every web 2.0 application relies on JavaScript to deliver front end interactivity. A growing list of JavaScript libraries (over 200+) are being created by various Ajax developers, some of which have gathered significant community adoption.
Though the usage of JavaScript code can lead to [...]]]></description>
			<content:encoded><![CDATA[<p>The wild popularity of Ajax fueled widespread usage of JavaScript.  Almost every web 2.0 application relies on JavaScript to deliver front end interactivity. A growing list of JavaScript libraries (over 200+) are being created by various Ajax developers, some of which have gathered significant community adoption.</p>
<p>Though the usage of JavaScript code can lead to significant better overall user experience, it can also bring problems if not used properly. Some of the common performance related problems are:</p>
<ol>
<li>Sluggish network and runtime performance.  It is common to see web pages that load several hundred kilobytes of JavaScript. The size of JavaScript libraries ranges from kilobytes to several hundred kilobytes, or even megabytes. Big footprint introduces not only longer download/parsing time, but also bigger client side memory/CPU footprint. For some browsers, parsing/processing large script can take an excessive amount of time (Firefox bug #313967);</li>
<li>The browser freezes from time to time. There are many cases that JavaScript code can slow down the entire browser instance. For example, too many JavaScript files that need to be loaded may cause excessive number of network round trips; the execution of a long running JavaScript function can block the browser from responding to user events until the function finishes, etc.</li>
</ol>
<p>There are a variety of techniques people use today to optimize JavaScript performance. Some of popular ones are:</p>
<ol>
<li>On-demand loading (lazy loading)
<p>Instead of loading all JavaScript files up front, loading them only when necessary can reduce the upfront network impact. A lot of JavaScript libraries provide such functionality, such as YUI loader and Dojo&#8217;s package system.</li>
<li>Concatenation
<p>Concatenation is an effective way to reduce the number of round trips. Instead of loading different JavaScript files using separate HTTP requests, concatenating these files into one file would enable all of them to be loaded using one HTTP request. Dojo ShrinkSafe and YUI Compressor are two popular tools that supports file concatenation.</li>
<li>Minimization (and Obfuscation)
<p>JavaScript programs are delivered to the client side as plain text where it is compiled on the fly and executed. However, there are two downsides of this approach. The first is code size. The source can contain materials (such as whitespace and comments) that are not necessary for code execution but rather for the purpose of aiding human readability of the code. Such materials have negative performance impact. The second side effect is lack of code privacy. Given that the code is delivered as plain text, someone could read it, learn our techniques, and may even gather hints from the source code on how to compromise our security.</p>
<p>JavaScript minimization and obfuscation are techniques to deal with both issues. Minimization removes the comments and unnecessary whitespace from JavaScript source code. Obfuscation changes the names of variables, functions, and members to strings that are harder to understand (and typically shorter).</p>
<p>JavaScript tools typically implement support for both obfuscation and minimization. Some of the popular tools are (see References):</p>
<ul>
<li>Dojo ShrinkSafe</li>
<li>YUI Compressor</li>
<li>Dean Edward’s JS Packer</li>
<li>JSMin</li>
</ul>
</li>
</ol>
<p>Applying the above techniques, it is possible to achieve a footprint reduction of 20% to 50%.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/10/27/javascript-optimization-techniques-today.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/10/27/javascript-optimization-techniques-today.html</feedburner:origLink></item>
		<item>
		<title>Yahoo’s Performance Rules</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/36sPRWNGDvc/yahoo%e2%80%99s-performance-rules.html</link>
		<comments>http://www.coachwei.com/blog/2008/10/27/yahoo%e2%80%99s-performance-rules.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 10:04:14 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[web 2.0]]></category>

		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=285</guid>
		<description><![CDATA[Yahoo’s Performance team summarized their experience in web performance optimization into 14 rules in general (Reference 4, http://stevesouders.com/examples/rules.php):
1.	Make Fewer HTTP Requests
2.	Use a Content Delivery Network
3.	Add an Expires Header
4.	Gzip Components
5.	Put Stylesheets at the Top
6.	Put Scripts at the Bottom
7.	Avoid CSS Expressions
8.	Make JavaScript and CSS External
9.	Reduce DNS Lookups
10.	Minify JavaScript
11.	Avoid Redirects
12.	Remove Duplicate Scripts
13.	Configure ETags
14.	Make AJAX Cacheable
]]></description>
			<content:encoded><![CDATA[<p>Yahoo’s Performance team summarized their experience in web performance optimization into 14 rules in general (Reference 4, http://stevesouders.com/examples/rules.php):</p>
<p>1.	Make Fewer HTTP Requests<br />
2.	Use a Content Delivery Network<br />
3.	Add an Expires Header<br />
4.	Gzip Components<br />
5.	Put Stylesheets at the Top<br />
6.	Put Scripts at the Bottom<br />
7.	Avoid CSS Expressions<br />
8.	Make JavaScript and CSS External<br />
9.	Reduce DNS Lookups<br />
10.	Minify JavaScript<br />
11.	Avoid Redirects<br />
12.	Remove Duplicate Scripts<br />
13.	Configure ETags<br />
14.	Make AJAX Cacheable</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/10/27/yahoo%e2%80%99s-performance-rules.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/10/27/yahoo%e2%80%99s-performance-rules.html</feedburner:origLink></item>
		<item>
		<title>Front End Performance and Today’s Typical Web Sites</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/-TSgd1zu_ZI/front-end-performance-and-todays-typical-web-sites.html</link>
		<comments>http://www.coachwei.com/blog/2008/10/27/front-end-performance-and-todays-typical-web-sites.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 09:49:55 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[Main Page]]></category>

		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[performance optimization]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=284</guid>
		<description><![CDATA[In order to understand how the front end, especially JavaScript, is impacting web performance today, some typical web pages were studied. The following table shows content composition of the front pages of two representative web sites, American Airline (www.aa.com) and FaceBook (www.facebook.com):
Table 1: Content Composition of Selected Web Sites




aa.com   front page Size (%)

Facebook.com [...]]]></description>
			<content:encoded><![CDATA[<p>In order to understand how the front end, especially JavaScript, is impacting web performance today, some typical web pages were studied. The following table shows content composition of the front pages of two representative web sites, <a href="http://www.aa.com">American Airline (www.aa.com)</a> and <a href="http://www.facebook.com">FaceBook (www.facebook.com)</a>:</p>
<p class="MsoCaption">Table 1: Content Composition of Selected Web Sites</p>
<table border="0">
<tbody>
<tr>
<td></td>
<td>aa.com   front page Size (%)</td>
<td>
<p>Facebook.com   front page Size (%)
</td>
</tr>
<tr>
<td>
Total   footprint:
</td>
<td>
810KB   (100%)
</td>
<td>
687KB   (100%)
</td>
</tr>
<tr>
<td>
JavaScript:
</td>
<td>
334KB   (42%)
</td>
<td>
532KB   (77%)
</td>
</tr>
<tr>
<td>
HTML
</td>
<td>
182KB   (23%)
</td>
<td>
23KB   (3%)
</td>
</tr>
<tr>
<td>
Images   (.gif, .jpg, .png)
</td>
<td>
201KB   (29%)
</td>
<td>
78KB   (11%)
</td>
</tr>
<tr>
<td>
CSS   files
</td>
<td>
69KB   (9%)
</td>
<td>
45KB   (7%)
</td>
</tr>
</tbody>
</table>
<p><a href="http://www.coachwei.com/wp-content/uploads/2008/10/aaandfacebook.png"><img class="aligncenter size-full wp-image-278" title="aaandfacebook" src="http://www.coachwei.com/wp-content/uploads/2008/10/aaandfacebook.png" alt="" width="500" height="128" /></a></p>
<div>Figure 2: Front Page of aa.com and facebook.com</div>
<p>In both cases, the initial HTML text is only a small percentage of the page footprint (23% and 3% respectively). This is generally true for web pages today. Secondly, the biggest portion of both pages is JavaScript, at 42% and 77% respectively. It is not uncommon to find web sites today that JavaScript comprises 40% to 90% of the footprint.</p>
<p>Further, various researches concluded that the front end is where majority of the page loading time is spent for today’s web pages. For example, Yahoo’s Web Performance team studied some major web sites’ front page loading time as shown in table 2. The result show that, in average,  only 5% to 20% of the page loading time is caused by server processing and network transfer of the initial HTML content while up to 90% of page loading time is spent processing the content: (Reference 2: http://yuiblog.com/blog/2006/11/28/performance-research-part-1/):</p>
<table id="time-spent-loading-popular-web-sites" class="chart" border="0">
<caption>Table 2. Time spent loading popular web sites</caption>
<tbody>
<tr>
<td class="empty"></td>
<th>Time Retrieving HTML</th>
<th>Time Elsewhere</th>
</tr>
<tr>
<th>Yahoo!</th>
<td>10%</td>
<td>90%</td>
</tr>
<tr>
<th>Google</th>
<td>25%</td>
<td>75%</td>
</tr>
<tr>
<th>MySpace</th>
<td>9%</td>
<td>91%</td>
</tr>
<tr>
<th>MSN</th>
<td>5%</td>
<td>95%</td>
</tr>
<tr>
<th>ebay</th>
<td>5%</td>
<td>95%</td>
</tr>
<tr>
<th>Amazon</th>
<td>38%</td>
<td>62%</td>
</tr>
<tr>
<th>YouTube</th>
<td>9%</td>
<td>91%</td>
</tr>
<tr>
<th>CNN</th>
<td>15%</td>
<td>85%</td>
</tr>
</tbody>
</table>
<p>
As a result, Yahoo team concluded a “performance golden rule” in reference 3: <i>optimize front-end performance first, that&#8217;s where 80% or more of the end-user response time is spent.</i>
</p>
<p>
In summary, for today’s web pages:<br />
<UL><br />
<LI>The server time for generating HTML content and network transfer time for such content are only small factors in page performance, typically only 5% to 20% of the page loading time. </LI><br />
<LI>Front end processing time can be as high as 95% of page loading time. </LI><br />
<LI>HTML is only a small portion of the footprint while JavaScript can be a significant portion of the footprint, sometimes as high as 80% to 90%; </LI><br />
<LI>JavaScript code performance can be the major performance influencer. </LI><br />
</UL></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/10/27/front-end-performance-and-todays-typical-web-sites.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/10/27/front-end-performance-and-todays-typical-web-sites.html</feedburner:origLink></item>
		<item>
		<title>Web Peformance Factors</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/WH05Wikxhbc/web-peformance-factors.html</link>
		<comments>http://www.coachwei.com/blog/2008/10/27/web-peformance-factors.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 09:28:55 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=276</guid>
		<description><![CDATA[Every web application requires satisfactory performance in order to be functional. Every web application has its own context that different factors influence performance differently. Since the beginning of the web, there have been many performance tuning endeavors responding to what the context calls for.

A good metric to gauge web performance is page loading time. Page [...]]]></description>
			<content:encoded><![CDATA[<p>Every web application requires satisfactory performance in order to be functional. Every web application has its own context that different factors influence performance differently.<span> </span>Since the beginning of the web, there have been many performance tuning endeavors responding to what the context calls for.</p>
</p>
<p>A good metric to gauge web performance is page loading time. Page loading time refers to the time from when browser issues the page URL request to the moment when the page is loaded, rendered and ready for user interaction. Page loading time is determined by three factors:</p>
<ul  type="disc">
<li><strong>Server processing time</strong>: the amount      of time that the server takes to process a page request and deliver the      response to the client;</li>
<li><strong>Network transfer time</strong>: The amount      of time that it takes to transfer the content from one end point to the      other end point;</li>
<li><strong>Front end processing time</strong>:<span> </span>the amount of time that the client      (browser) takes to process the content it received, including parsing,      loading additional resources when required and rendering.</li>
</ul>
<p>Given that web applications are distributed across web server, network and web browser, all of the three factors play a role in performance. However, the relative importance of each factor is different, which is largely related to the web architecture.</p>
</p>
<p>Historically, the web architecture was server-centric. All (or almost all) intelligence stayed on the server side and there was very little intelligence on the client side. The browser requires very little “intelligence” besides acting as a “dumb display terminal”. Further, web content were mostly plain HTML pages that consume very little network resources to transfer. In this model, the performance bottleneck was typically on the server side and server processing time was the biggest performance factor. As a result, most of the earlier web performance optimization efforts focused optimizing server side processing, such as using more powerful servers, database tuning, optimizing server side logic, etc.</p>
</p>
<p>As web pages grew richer, the number of external objects, such as graphical images, included in web pages started to grow. Because external objects require network round trips, the impact of network transfer started to become more visible, especially when transferring content internationally. HTTP caching was adopted to alleviate the network impact. Further, content delivery services (CDN), which are mostly based on HTTP caching techniques, grew into an industry dedicated at improving network performance for delivering web content.</p>
</p>
<p>Over the last several years, we witnessed the so-called “Web 2.0” evolution. Driven by a need to deliver a richer user experience, the web’s architecture has shifted away from being 100% server-centric into an architecture that leverages both client side and server side processing power. Putting data and intelligence to where the user is at significantly improves user experience by reducing server round trips. As a result, in today’s web 2.0 environment, the client side is taking on more data and computation.<span> </span>According to Reference 1, from 1995 to 2008, the size of an average web page has increased 22 times, and the number of external objects per page has grown 21.7 times. From 2003 to 2008, the average web page grew from 93.7K to over 312K (233%) and the number of external objects in the average web page nearly doubled from 25.7 to 49.9 external objects per page. Because JavaScript is the only supported way to implement client side intelligence, today’s web applications tend to employ a significant amount of JavaScript code.</p>
</p>
<p>Consequentially, this Web 2.0 evolution significantly changed the comparative importance of web performance factors. For the first time, front end processing time is becoming the biggest factor in web performance while server side processing time and network transfer time are both becoming secondary.</p>
<p><a href="http://www.coachwei.com/wp-content/uploads/2008/10/webpeformancefactors.png"><img class="size-medium wp-image-277" title="webpeformancefactors" src="http://www.coachwei.com/wp-content/uploads/2008/10/webpeformancefactors-300x207.png" alt="" /></a></p>
<p class="MsoCaption">Figure 1: The Changing Relative Importance of Performance Factors with the Evolution of the Web</p>
<p>More specifically, among front end processing, client side JavaScript code is becoming one of the top influencers on the overall performance due to the increasingly dependency of web applications on JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/10/27/web-peformance-factors.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/10/27/web-peformance-factors.html</feedburner:origLink></item>
		<item>
		<title>Running Toronto Marathon - 9/28/2008</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/uVNClkGwBXY/running-toronto-marathon.html</link>
		<comments>http://www.coachwei.com/blog/2008/09/30/running-toronto-marathon.html#comments</comments>
		<pubDate>Wed, 01 Oct 2008 04:28:13 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[marathon]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=273</guid>
		<description><![CDATA[A couple of years ago my friend Kaushal Vyas blogged about his first marathon experience. His blog entry started with some quotes from Lance Armstrong on his first marathon:
“the hardest physical thing I have ever done. Even the worst days in the tours, nothing was as hard as that and nothing left me feeling the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago my friend <a href="http://ahimsa-marg.blogspot.com/2006/12/white-rock-marathon.html">Kaushal Vyas</a> blogged about his first marathon experience. His blog entry started with some quotes from Lance Armstrong on his first marathon:</p>
<p><span style="color: #0000ff;">“the hardest physical thing I have ever done. Even the worst days in the tours, nothing was as hard as that and nothing left me feeling the way I feel now in terms of sheer fatigue and soreness. I think I bit off more than I could chew, I thought the marathon would be easier&#8230;”</span>.</p>
<p>It didn&#8217;t resonate with me at the time. In fact, I didn&#8217;t feel anything besides saying &#8220;wah, cool&#8221;. What I didn&#8217;t know (I&#8217;m sure Kaushal didn&#8217;t know either) is that he planted some seeds in me at the time that would only grow two years later.</p>
<p>In Boston where I live(Kaushal lives in LA), my friend Ying actually has been running marathon many times. I always admired her for such achievements. Every time when she encouraged people to run, I always thought &#8220;nanh, not me&#8221;.</p>
<p>I know myself - I was never a good runner. My body type is not built for running with a BMI of 27. I hated running long distance when I was in middle school. Over the last few years, I did do some running here and there along the river, only because i wanted to take some time to think of things. Further, I&#8217;ve never been able to run for more than 2-3 miles without stopping. 26 miles? It is just way out of my league.</p>
<p>In June 2008, Cliff (of <a href="http://literacybridge.org/">LiteracyBridge</a>, very cool non-profit startup) and I somehow got into talking about marathon. His background is similar to mine (never enjoyed running, never run more than 3 miles, &#8230;) but he did it. What I learned from him is &#8220;a non-runner&#8217;s guide to marathon&#8221;. Yes, that&#8217;s me - a non-runner.</p>
<p>So I dipped my toe into training. Two friends(Ying and Jana) were training for the September 2008 Toronto race. I joined them in the end of June. Normal marathon training takes about 16 weeks. So my time was a little bit short, but I figured that I am not trying to win the first place and I can drop out if it turns out to be too much, so I went for it.</p>
<p><strong>The Training</strong><br />
The training was actually quite enjoyable, because marathon training schedules are all designed to take someone from 3 mile run to 26 miles in a gradual, incremental fashion. Every few weeks, the running mileage increases, but still within the limits of a normal human body. Such increases give a real sense of accomplishment that keeps one going.</p>
<p>I did have challenges almost all the time though. In the first month or so, my calves were very sore that I have to stop running from time to time. I thought my calves were injured. It turned out that it was probably just weak. After a month, the calves problem went away. The I ran into breathing problem, having pains below my right ankle, thigh problems&#8230;. one problem after another one. But nothing was serious to stop the training.</p>
<p><strong>August 31 2008</strong><br />
On August 31 2008(four weeks before the race), I successfully completed a 21 mile run under four hours. I was very tired after the run, but my body felt good. There was no injury or pain. I felt for the first time that I can run marathon. That&#8217;s the time that I actually registered for the race.</p>
<p><strong>September 7 2008</strong></p>
<div  class='alignleft' style="margin:5px;"><img src='http://www.gobros.com/gc/files/mcdavid/425_blk_dt.jpg' alt='' /><br/><b>McDavid Ligament Black 425</b></div>
<p>Three weeks before the race: we were trying to run another 20+ mile run in the morning. I had too much wine the night before and went to bed fairly late (2am?). I didn&#8217;t feel good running. I kept telling my running partners that I &#8220;am very sleepy&#8221; during the run. Bad things happened then. After the 13th mile, I suddenly felt a sharp pain on the outside of my left knee. The pain was so severe that I couldn&#8217;t run anymore. I walked for 5 miles to finish the route. But I wasn&#8217;t too worried, thinking of it as a glitch that will go away if I&#8217;m better rested next time. My running partners told me to take Ibuprofen, and have plenty of rest.</p>
<p><strong>September 17 2008</strong><br />
Typical training schedule ends after a couple of 20+ mile long runs, which would be sufficient to run the marathon. On Sept 17, I decided to do a 14-mile run to see whether my knee has fully recovered. I also put on knee braces for extra support. After ten miles, I felt early signs of knee problem again. I knew it would develop into sharp pains in a couple of miles. With only 10 days to go before the race, I started to worry whether I can run the marathon.</p>
<p>The problem I have is called &#8220;ITBS&#8221; (Iliotibial Band Syndrome), a very common problem for runners. After consulting various sources, I stopped running. Instead, I started taking Ibuprofen, doing ITBS exercises, and swimming every day, hoping to put the problem under control.</p>
<p><strong>September 25 2008</strong></p>
<p>With only three days to go, we went for the last run, a 2.5 mile short run. Both Jana and I didn&#8217;t feel good about our knees after this run. Fortunately we found some good strong knee braces, McDavid&#8217;s Ligament Black 425.  This knee brace is so good that we both gained confidence again. </p>
<p><strong>Racing Day - September 28 2008</strong><br />
Marathon races typically start at 7:30AM, and requires participants to line up one hour before that. Having to get up at 5AM killed me. But being together with so many runners, it was exciting. We crossed the starting line around 7:40AM. The route started at Toronto&#8217;s City Hall, then went down along the waterfront to the east. I felt fine besides being a little bit sleepy. while praying my knee is going to be OK.</p>
<p><a href="http://www.torontowaterfrontmarathon.com/photos/2008/overview/images/039TA092808-Marathon2.jpg"><img src="http://www.torontowaterfrontmarathon.com/photos/2008/overview/images/039TA092808-Marathon2.jpg" alt="" /></a></p>
<p>After about 2-3 kilometers, my left leg started to feel numb, probably because the knee brace was too tight. Having problems this early is obviously bad. I slowed down, completely loosened the belts on the brace. Loosening the belts means taking a big risk in giving up a lot of of knee support. But I had no choice. After another kilometer or so, the worst happened. My knee started hurting. It may soon develop into sharp pains that would stop me from running.</p>
<p>This was not even 5 kilometers yet! I have to face the possibility of dropping out of the race. But not even completing 5 kilometers would be a real shame! While I resisted the idea of dropping out, I knew it would be unlikely that I&#8217;d be able to finish the race today. It was a bitter realization, and all what I could hope for was to run a decent distance worthy of my training.</p>
<p>So I tried to figure out ways that could help me last as far as I could. First of all, I tightened my knee brace belts to delay the knee pain from further development. Secondly, I tried to minimize the usage of my left leg. In fact, my left foot didn&#8217;t touch the ground except for a few toes, basically hopping/limping along by putting most of my weight and forces on my right leg.</p>
<p>With the new strategy, I finished 12 kilometers. Fortunately the knee problem didn&#8217;t seem to develop further. However, the unnatural running position made my body very tired. With 30 more kilos ahead, I knew the impossibility of finishing the run. Mentally I started to prepare for dropping out of the race at half marathon.</p>
<p>At 18th kilometer, half marathon runners were instructed to stay to the left of the road and marathon runners on the right side. 90% runners went to the left side. The right side was actually relatively empty. For some strange reason, I decided to stay on the right side of the road. Not sure what I was thinking at that moment. My right leg was really tired and I had to walk instead of running a few times to give my right leg a break. For the next several kilometers, every kilometer was a struggle. My body was very weak. I was struggling to fight off the idea of dropping out and getting this over.</p>
<p>After 26th kilo, it was as if my training started to kick in. I started to feel some strength coming back into my body. When I crossed 28 kilo, someone cheered &#8220;you&#8217;ve finished 2/3&#8243;. My mental state suddenly changed. At that moment, I realized that I will not drop out and will finish the race.</p>
<p>The rest of the journey was difficult, but nothing insurmountable. The last 1200 meters were actually quite enjoyable (given that so many friendly people were cheering for me). I crossed the finished line, and saw my running partners holding cameras towards me. Exhausted, but felt invincible.</p>
<p><strong>In the End</strong><br />
I finished the run in 5 hour 35 minutes, a lot longer than I hoped for. However, I was thrilled to have finished the race without dropping out considering that I have to run on one leg most of the time and the mental torture associated with it. Self doubt is the worst enemy and I had it with me until I finished the 28 kilo. Yes, a lot of things in life depend on mental strength, rather on the sheer physical strength.</p>
<p><a href="http://www.coachwei.com/wp-content/uploads/2008/10/toronto-marathon1.jpg"><img class="alignleft size-medium wp-image-274" style="margin: 4px;" title="marathon1" src="http://www.coachwei.com/wp-content/uploads/2008/10/toronto-marathon1.jpg" alt="marathon outfit and medal" /></a></p>
<p>Physically, to be honest, I was exhausted after the race. However, I could have run another couple miles though, because in the end, running was just something to do. I hit the wall early - from the 15th to the 25th kilometer. That was the time I was most exhausted, had very little faith in myself and couldn&#8217;t see the light in the end of the tunnel. It was dark as the deepest night even in the end of the 27th kilo. But the moment I turned into the 28th, I knew I got it.</p>
<p>I can see myself run better when someone was cheering for me. My friends, running partners, family and the friendly Toronto people were doing an incredible job at cheering for me. Big thanks!</p>
<p>In retrospect, I wasn&#8217;t totally well prepared. I have yet to develop more strength around my left knee to support running a marathon. Consequences? My left knee still hurts. One of my left toe nails was full of blood. I also discovered my knee brace has cut a half ring into my skin, right behind my knee cap. Nevertheless, it felt really good!</p>
<p>If I can do it, so can you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/09/30/running-toronto-marathon.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/09/30/running-toronto-marathon.html</feedburner:origLink></item>
		<item>
		<title>JavaScript Execution Context, Closure, Eval and “this” Keyword</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/reWMMxSZcNo/javascript-execution-context-closure-eval-and-this-keyword.html</link>
		<comments>http://www.coachwei.com/blog/2008/09/13/javascript-execution-context-closure-eval-and-this-keyword.html#comments</comments>
		<pubDate>Sun, 14 Sep 2008 03:36:23 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[activation object]]></category>

		<category><![CDATA[eval]]></category>

		<category><![CDATA[function scope]]></category>

		<category><![CDATA[Javascript closure]]></category>

		<category><![CDATA[Javascript execution context]]></category>

		<category><![CDATA[scope]]></category>

		<category><![CDATA[scope chain]]></category>

		<category><![CDATA[this]]></category>

		<category><![CDATA[variable object]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=272</guid>
		<description><![CDATA[These are a few key concepts of JavaScript language that developers should know: execution context, activation object, variable instantiation, scoping, closure, eval and &#8220;this&#8221; keyword.  Knowing these would help one tremendously in Ajax development. 
For example, when you write an inner function, you know that you can access the local variables defined in the [...]]]></description>
			<content:encoded><![CDATA[<p>These are a few key concepts of JavaScript language that developers should know: execution context, activation object, variable instantiation, scoping, closure, eval and &#8220;this&#8221; keyword.  Knowing these would help one tremendously in Ajax development. </p>
<p>For example, when you write an inner function, you know that you can access the local variables defined in the outer function as if they were defined locally. You can also access the global variables. -Why? How does the host environment resolve such variables?</p>
<p>Another example: When you pass arguments to a function, you can access these arguments as if they were locally defined variables. How does this work?</p>
<p>A slightly more involved example that developers must have seem similar code a lot but may not know the &#8220;why&#8221;:</p>
<pre>
function outerFunc(outerArg){
   var localVar = 100;

   function innerFunc(innerArg){
      localVar+=100;
       return (outerArg +innerArg + localVar);
    }

   return innerFunc;
}

 var globalVar = outerFunc(200);
 alert(globalVar(300));	//this displays 700
 alert(globalVar(300));	//this displays 800
 globalVar = outerFunc(200)
 alert(globalVar(300));  //this displays 700 again
</pre>
<p>Why would the 2nd alert box show 800 (means the value of <code>localVar</code> is retained from the first call) while the third alert displays 700 (the value of <code>localVar</code> is not retained from previous calls)? How does it work?</p>
<ol> <b>Key Concepts</b></p>
<li><strong>Execution Context</strong>:<br />
An execution context is an abstract concept used by the EcmaScript specification and  can be conceived (and even implemented) as a set of objects with properties, though not publicly accessible, that encapsulate the context in which a piece of JavaScript code executes. The JavaScript code would rely on its execution context for things like variable resolution and scoping. </p>
<p>
All JavaScript code executes in an execution context. Global code (code executed inline, normally as a JS file, or HTML page, loads) gets executed in a global execution context (in a browser, the global context is typically the <span class="code">window</span> object), and each invocation of a function (possibly as a constructor) has an associated execution context. Code executed with the <span class="code">eval</span> and <code>setTimeout</code> functions also gets a distinct execution context.
</p>
<p>When a JavaScript function is called,  it enters an execution context. If another function is called (or the same function recursively),  a new execution context is created and execution enters that context for the duration of the function call. When that called function returns,   control returns to the original execution context and the just finished execution context is available for garbage collection except for cases like <strong>closure</strong>. Thus running JavaScript code forms a stack of execution contexts.</li>
<li><strong>Activation Object and Variable Object </strong>:<br />
<OL><br />
<LI>Activation Object:<br />
When an execution context is created, an <b>Activation Object</b> is created. The Activation Object can be considered as a normal JavaScript object with accessible named properties, except that it has no prototype and it cannot be directly referenced by javaScript code.This Activation Object is used for storing context related information such as call arguments and variables, etc. so that they are accessible to the new execution context (see more info on this later in this post).<br />
</LI><br />
<LI>Variable Object  and Variable Instantiation:<br />
ECMA Specification refers to a &#8220;Variable Object&#8221; for variable instantiation.  &#8220;Variable Instantiation&#8221; is a process that takes place when the JavaScript host environment processes a piece of script so that it can be executed but before executing the script. In this process, the JavaScript engine prepares(&#8221;instantiates&#8221;) the local variables, local functions declarations, and arguments to the function call etc. so that these variables are accessible during execution. </p>
<p>The way that variable instantiation works is to instantiate each of the function&#8217;s formal parameters, local variables and inner function declarations as named properties of the Variable Object. In the process, named properties of the Variable object are created for each of the function&#8217;s formal parameters. If arguments to the function call correspond with those parameters,  the values of those arguments are assigned to the properties (otherwise the assigned value is undefined). If there is an inner function declaration,  a function object is created. This function object is assigned a property of the Variable object with name corresponding to the function name used in the function declaration. The last stage of variable instantiation is to create named properties of the Variable object that correspond with all the local variables declared within the function.</p>
<p>The properties created on the Variable object that correspond with declared local variables are initially assigned undefined values during variable instantiation, the actual initialization of local variables does not happen until the evaluation of the corresponding assignment expressions during the execution of the function body code.</p>
<p>However, it is very important to point out that the <b>Activation object is used as the Variable object</b>. Though conceptually they are called out as different objects, they are the same object in reality. This is important as you can see quickly in &#8220;scope and scope chain&#8221; and &#8220;variable resolution&#8221; later on. </p>
<p>It is the fact that the Activation object, with its <code>arguments</code> property, and the Variable object, with named properties corresponding with function local variables, are the same object, that allows the identifier <code>arguments</code> to be treated as if it were a function local variable.</p>
<p></LI></OL></LI><br />
<LI><strong>Scope, Scope Chain and Variable Resolution:</strong><br />
Each execution context has an assigned scope when created. A <b>scope</b> can be thought of as an &#8220;object&#8221; that is associated with a particular execution context (this scope object is actually the Activation Object we mentioned above). A <b>scope chain</b> consists of a list (or chain) of such objects. The scope chain of an execution context is a chain of objects with the current &#8220;scope&#8221; object on the top, the &#8220;scope&#8221; object of the calling execution context as the 2nd object on the top, and so on, with the last &#8220;scope&#8221; object of the chain being that of the global execution context. </p>
<p>What do <code>scope</code> and <code>scope chain</code> do? They are used for <b>variable resolution</b>. When some JavaScript refers to a variable <code>"foo"</code>, the host environment will try to resolve this variable. This resolution process is against the scope chain of the current execution context.  First, it will search to see if there is a variable with the same name in the current scope. This is done by checking to see if the current &#8220;scope&#8221; object has such a named property. Remember that we mentioned Activation Object and Variable Object are the same object, and local variables (including  inner function declarations, and function arguments) are instantiated as named properties of the Variable object during variable instantiation. So if the &#8220;foo&#8221; variable is defined in the local execution context, there must be a property of the Variable object named &#8220;foo&#8221;.   If such a named property is not found, it means this &#8220;foo&#8221; variable is not defined here. The resolution process will now go down the scope chain and check against the 2nd &#8220;scope&#8221; object and so on until such such a named property is found or otherwise an &#8220;undefined&#8221; error happens </p>
<p>(BTW:  Prototype chain is always part of property resolution process and no difference here either. The normal prototype chain lookup process applies when looking for a property with a specific name from a &#8220;scope&#8221; object: If no such property is found on the object itself, the prototype object will be searched. Still not found, the prototype of the prototype object will be searched. Until either the property is found or the end of the prototype chain is reached). </p>
<p>Important to point out: each function object has an internal property called <code>[[scope]]</code> (see more info on this later in this post) that consists of a list (or chain) of objects. This <code>[[scope]]</code> property can not be directly referenced by JavaScript code.  When the function object is created, its internal <code>[[scope]]</code> property is assigned to the execution context in which this function object is created. This execution context has its own scope object and so on. In the end,  the <code>[[scope]]</code> property is associated with a scope chain with the execution context in which the function object is created being on the top. </p>
<p>The scope chain of the execution context of a function call consists of the list referred to by the <code>[[scope]]</code> property of the corresponding function object and the Activation object created for this function call. The activation object is at the front of the chain (or the top of the list).<br />
</LI></p>
<li><strong>Automatic Garbage Collection</strong>:<br />
Yes, automatic garbage collection is not a Java specialty. EcmaScript uses automatic garbage collection too.  If an object becomes un-referable (by having no remaining references to it left accessible to executing code),  it becomes available for garbage collection and will at some future time be destroyed and any resources it consumes freed and returned to the system for re-use.</p>
<p>This would normally be the case upon exiting an execution context.  Any objects created within the exited execution context, including function objects, would no longer be accessible and so would become available for garbage collection. However, <strong>Closure</strong> is the exception. </p>
<li><strong>Closure</strong>:</li>
<p>A closure is an expression (typically a function) that can have free variables together with an environment that binds those variables (that &#8220;closes&#8221; the expression). A closure is formed by returning a function object that was created within an execution context of a function call  and assigning an accessible reference to that inner function.  The accessible reference can be established by directly assigning the returned function object to a global variable, a property of a globally accessible object or an object passed by reference as an argument to the outer function call, etc. </p>
<p>In the code example above, line <span class="code">&#8220;var globalVar = outerFunc(200);&#8221;</span> calls the outer function <code>"outerFunc"</code>. This call returns an inner function object and this returned inner function object is assigned to a global variable called <code>globalVar</code>. As a result, a closure is formed here.
</li>
<li><b>Summary and the Global Execution Context</b>
<p>The key concepts of execution context can be summarized using the following illustrations (assuming the function is named <code>"foo"</code>):</p>
<pre>
   The Execution Context of a call to function "foo":
           . Activation object
           . Variable object
           . Scope chain
</pre>
<p>The <code>[[scope]] </code> property of function object &#8220;foo&#8221; is:</p>
<pre>
    foo.scope:
          = the scope chain of the execution context where "foo" is created
</pre>
<p>Further, the relationship between the above objects are:</p>
<pre>

   The Execution Context of a call to function "foo":
         .Activation object: = Variable object
                 .arguments
                 .local variables
                 .local function declarations
         .Scope chain:
                     = Activation object + foo.scope
</pre>
<p>The global execution context gets some slightly different handling:<br />
1.  As it does not have arguments so it does not need a defined Activation object to refer to them;<br />
2.  The global execution context does need a scope and its scope chain consists of exactly one object, the global object itself (<code>window</code> object).<br />
3.  The global execution context does go through variable instantiation just like any other context;<br />
4.  The global object itself is used as the Variable object, which is why global functions and variables become properties of the global object.
</li>
</ol>
<p><b>How Does A JavaScript Function Get Executed?</b></p>
<p>The JavaScript engine goes through several steps in calling a JavaScript function (say the function is named <code>"foo"</code> for reference purposes): </p>
<ol>
<li>First of all, it creates a new <em> Execution Context</em> for this function call. The creation of an <em>Execution Context</em> follows the following steps:
<ol>
<li>Create an <em>Activation Object</em>;</li>
<li>Create an <em>arguments</em> object with <code>length</code> and <code>callee</code> properties specified. This <code>argument</code> object is an array-like object with integer indexed members corresponding to the arguments passed to the function call, in the order of their appearance. It also has <code>length</code> and <code>callee</code> properties instantiated. Next, a property named <code>"arguments"</code> is created for the Activation Object and a reference to this <code>arguments</code> object is assigned to this property;
</li>
<li>Variable Instantiation: assign local variables, inner function declarations and declared function parameters as such named properties of this <code>Activation Object</code>, with value being &#8220;undefined&#8221; for local variables and non-instantiated function call parameters (more on the values later, and also more on how  functions are instantiated and assigned               <code>[[scope]]</code> property later).
</li>
<li>Assign the <em>&#8220;this&#8221;</em> keyword (more on <code>"this"</code> keyword later);</li>
<li>Assign &#8220;scope&#8221; and &#8220;scope chain&#8221; to this execution context:<br />
          <UL><br />
           <LI>&#8220;scope&#8221; = the Activation Object:</li>
<p>            <LI>&#8220;scope chain&#8221; = the Activation Object + the chain referred to by the <em>[[scope]]</em> property of this function object <em>&#8220;foo&#8221;</em>. </li>
<p>           </UL>
        </li>
</ol>
<p>  Now the execution context of this function call is created and we are ready to call the function.
</li>
<p><LI>Call function &#8220;foo&#8221; and executes its code line by line:<br />
       <UL><br />
            <LI>For each variable that the execution process runs into, resolve it according to the variable resolution rule by looking at the local Activation object first, then the calling execution context&#8217;s Activation object, and so on, until the end of the scope chain which should be the &#8220;Activation Object&#8221; of the global execution context (a side note: for performance reasons, you can see why referencing a global variable using <code>window["variableName"]</code> would be better than using <code>"variableName"</code> directly);<br />
             </LI><br />
            <LI>For each local variable (remember we said earlier that their values are &#8220;undefined&#8221; during variable instantiation), evaluate the variable&#8217;s assignment expression (if there is one) and assigns the result to it (actually, assigns the result to such a named property of the Activation Object);<br />
            </LI><br />
            <LI> If the execution process runs into a function call (let&#8217;s call it function &#8220;foo2&#8243;), a new execution context (let&#8217;s call this &#8220;context foo2&#8243;) is created for this function call. In &#8220;context foo2&#8243;:<br />
                  <OL><br />
                     <LI>a new Activation Object (&#8221;Activation object foo2&#8243;)  is created;</LI><br />
                     <LI>Variable Instantiation is performed(using the Activation object(&#8221;Activation object foo2&#8243;) as Variable object);</LI><br />
                      <LI>The scope chain of &#8220;context foo2&#8243; is (&#8221;Activation object foo2&#8243;+ the scope chain of &#8220;foo&#8221;); </p>
<p>                    <LI>During the variable instantiation for this function call, if a function declaration (let&#8217;s call this function &#8220;foo3&#8243;) is found, a new function object (&#8221;foo3&#8243;) is created. a property named as the declared function&#8217;s name with value being this newly created function object will be added to the Activation object. </p>
<p>                    More importantly to point out, the <code>[[scope]]</code> property of this newly created function object <code>"foo3"</code> is the scope chain of the execution context where the instantiation happens - which is &#8220;context foo2&#8243; in this case. So <code>"foo3.scope"</code> is (&#8221;Activation object foo2&#8243;+ the scope chain of &#8220;foo&#8221;);<br />
                     </LI><br />
                     <LI>Eventually the function is called. Upon returning from this call, execution continues to the next line of function <code>"foo"</code>; </LI><br />
                 </OL><br />
            </LI><br />
            <LI>Finally, this call to function <code>"foo"</code> completes and we return to the callee. At this moment, unless a closure is formed, this execution context is available for garbage collection.<br />
            </LI><br />
       </UL><br />
</LI>
</ol>
<p><b>Function Instantiation</b></p>
<p>In JavaScript, &#8220;functions&#8221; are objects. Depending on how a function is defined, there are three ways to  instantiate a function object:<br />
<OL><br />
<LI><b>from function declaration during variable instantiation:</b><br />
If a function declaration is found during the process of variable instantiation, a function object will be created. The Activation Object will have a property whose name is the name of the function and whose value is the created function object. Further, This created function object will have its <code>[[scope]]</code> property assigned to be the scope chain of the execution context in which this function object is created.<br />
For example, in the following code snippet:</p>
<pre>
       function outerFunc() {
          var var1=10;
          function MyFunc1(){
                 return  var1=var1+1;
           };

          return MyFunc1();
        }

       alert(outerFunc()); //displays "11".
</pre>
<p>When the host environment is going to execute line <code>alert(outerFunc());</code>, in particular, when it is going to call <code>outerFunc()</code>, it will create a new Execution Context for this call (let&#8217;s name this new execution context <em>outerFuncContext1</em> for reference purpose). During the creation of <em>outerFuncContext1</em>, it will instantiate variables.  Both <code>"var1"</code> and <code>"MyFunc1"</code> are instantiated during this variable instantiation. Upon variable instantiation, the Activation Object associated with <em>outerFuncContext1</em> will have a property named <code>"var1"</code> whose value is &#8220;undefined&#8221;, and a property named <code>"MyFunc1"</code> whose value is a function object created here. Further, the <code>[[scope]]</code> property of this function object is assigned to be the scope chain of <em>outerFuncContext1</em>.<br />
</LI><br />
<LI><b>from the evaluation of a function expression during code execution.</b><br />
Consider the following snippet:</p>
<pre>
       function outerFunc() {
          var var1=10;
          var var2=function(){
                 return var1=var1+1;
           };

          return var2();
        }

       alert(outerFunc()); //displays "11".
</pre>
<p>When the host environment is going to call <code>outerFunc()</code>, it will create a new Execution Context for this call (again, let&#8217;s name this execution context <em>outerFuncContext1</em> for reference purpose). During the creation of <em>outerFuncContext1</em>, it will instantiate variables.  Both <code>"var1"</code> and <code>"var2"</code> are created during this variable instantiation. Upon variable instantiation, the Activation Object associated with <em>outerFuncContext1</em> will have a property named <code>"var1"</code> whose value is &#8220;undefined&#8221;, and a property named <code>"var2"</code> whose value is also &#8220;undefined&#8221;. </p>
<p>Then the host environment goes on to execute the call to <code>outerFunc()</code>. During execution, first it will assign <code>10</code> to <code>var1</code>. Then it will evaluate the function expression related to <code>var2</code>. During this evaluation, a function object is created and assigned to variable <code>var2</code>. Further, the <code>[[scope]]</code> property of this function object is assigned to be the scope chain of the execution context in which this function object is created, <em>outerFuncContext1</em>.<br />
</LI><br />
<LI><b>from invoking the <code>Function</code> constructor:</b><br />
In this case, the function&#8217;s <code>[[scope]]</code> property always refers to the scope chain of the global execution context, which contains only one object, the global object. An example is:</p>
<pre>
          var y=100;
          var multiply = new Function("x", "return x * y;");
          alert(10); //displays 1000.
</pre>
<p>In the above example, variable <code>y</code> is being searched in the global context. If there is no global variable named <code>"y"</code>, an error will be thrown.<br />
</LI></p>
<p><LI><b>Summary of function [[scope]]:</b><br />
In summary, every function object has an internal <code>[[scope]]</code> property that refers to a scope chain. This property is very important for figuring out the scope of execution context and thus variable resolution, etc:<br />
<UL><br />
   <LI>If the function object is created from a <code>Function</code> constructor, the <code>[[scope]]</code> property always refers to one object only, the global object. On browsers, it is the <code>"window"</code> object. </LI><br />
  <LI>If the function object is created from either function declaration or function expression evaluation, its <code>[[scope]]</code> property always refers to the scope chain of the execution context in which the function object is created. </LI><br />
</UL></LI></OL></p>
<p><b>The <code>"this"</code> Keyword</b></p>
<p>One of the most powerful JavaScript keywords is <code>"this"</code> and I am sure that every developer has used it many times. However, it is not straightforward to figure out what it points to. </p>
<p><code>"this"</code> is typically assigned an object that it points to during the process of creating a new execution context. If the value assigned refers to an object, then property accessors prefixed with the <code>"this"</code> keyword points to the properties of that object. However, if no object can be assigned to it, then the <code>"this"</code> keyword will point to the global object by default. </p>
<p>The next question is how do we know when/whether an Object will be assigned to <code>"this"</code> and who that Object is. For example, consider the following code:</p>
<pre>
      function redColor() {
                      this.color= 'red';
              }
     alert(redColor.color); //shows "undefined"
     var aa=redColor;
      alert("color="+aa.color); //shows color= undefined
</pre>
<p>What does not &#8220;color&#8221; become a property of <code>"aa"</code>? Further, functions are objects in JavaScript - why wouldn&#8217;t <code>"this"</code> refer to the function object &#8220;redColor&#8221; itself? </p>
<p>The rule to remember is that <code>"this"</code> always refers to the “owner” of the function we&#8217;re executing. In other words, <b>keyword <code>"this"</code> always refers to the object that the containing function is a method of</b>. </p>
<p>In the above example, the function <code>"redColor"</code> is not a method of object <code>"redColor"</code>, so <code>"redColor.color"</code> returns &#8220;undefined&#8221;. Further, function <code>"redColor"</code> is not a method of some object called <code>"aa"</code> either. So <code>"aa.color"</code> also returns &#8220;undefined&#8221;. </p>
<p>However, according to our understanding of how variable instantiation works, <code>"redColor"</code> is instantiated as a property of the global object. The global object has a property called <code>"redColor"</code> and the value of the property is the <code>"redColor"</code> function object. In  the end, <code>"function redColor"</code> is actually a method of the global object. According to the rule above, <code>"this"</code> should be referring to the global object.  </p>
<p>In other words, if we execute function <code>"redColor"</code>, we are actually assigning a &#8220;color&#8221; property to the global object with the value of &#8220;red&#8221;. If you run the following code:</p>
<pre>
	function redColor() {
              this.color = 'red';
      }

         redColor();
	 alert("window.color="+window.color);//shows window.color=red
</pre>
<p>The alert box shows &#8220;window.color=red&#8221;! </p>
<p>If you attach function <code>"redColor"</code> as a method of an object using <code>obj.method=redColor</code> or <code>obj.prototype.methodName=redColor</code>, the keyword <code>"this"</code> will correctly point to our <code>"obj"</code>. However, there is one case that people tend to make mistake, like the following:</p>
<pre>
          &lt;div id=&quot;mydiv&quot; onclick=&quot;redColor();&quot;&gt;This is my div&lt;/div&gt;
</pre

The code above is not able to set a "color" property for the "div" element at an "onclick" event, because <code>"redColor"</code> is still not a method of the &#8220;div&#8221; object. It is being called by a method of the &#8220;div&#8221; object called the <code>"onclick"</code>. As a result, the <code>"this"</code> keywork in the function body of <code>"redColor"</code> is not pointing to the &#8220;div&#8221; object as we hoped. The code below is the right way to achieve the goal of adding a <code>"color"</code> property to the &#8220;div&#8221; Object: 
<pre>
           var div=document.getElementById("mydiv");
           div.onclick=redColor;
</pre>
<p><b>The <code>"eval"</code> and <code>"setTimeout"</code> Functions </b><br />
Function <code>"eval" </code> and <code>"setTimeout"</code> have their own distinct execution context, as mentioned briefly ealier. <code>"setTimeout"</code> always assumes the global execution context. For <code>"eval"</code>, here is the quote from ECMASpecification:<br />
<quote><br />
&#8220;When control enters an execution context for eval code, the previous active execution context, referred to as the calling context, is used to determine the scope chain, the variable object, and the this value. If there is no calling context, then initializing the scope chain, variable instantiation, and determination of the this value are performed just as for global code.</p>
<p>The scope chain is initialized to contain the same objects, in the same order, as the calling context’s<br />
scope chain. This includes objects added to the calling context’s scope chain by with statements and<br />
catch clauses. </p>
<p>Variable instantiation is performed using the calling context’s variable object and using empty<br />
property attributes.</p>
<p>The this value is the same as the this value of the calling context.&#8221;<br />
</quote></p>
<p>In short, you can think of &#8220;eval&#8221; assuming the exact same execution context as the calling code. </p>
<p><OL><b>Further Readings and References </b><br />
<LI>&#8220;Microsoft AJAX Library - JavaScript Execution Context&#8221;, <a href="http://www.exforsys.com/tutorials/microsoft-ajax/javascript-execution-context/1.html">http://www.exforsys.com/tutorials/microsoft-ajax/javascript-execution-context/1.html</a>; (quick note: this doesn&#8217;t really have anything to do with Microsoft Ajax library. Further, &#8220;AJAX&#8221; should be spelled as &#8220;Ajax&#8221;. The &#8220;AJAX&#8221; spelling is so 2005!);<br />
</LI><br />
<LI>&#8220;Javascript Eval Scope Namespace Execution Context&#8221;, <a href="http://adrenalin.wordpress.com/2006/06/12/javascript-eval-scope-namespace-execution-context/">http://adrenalin.wordpress.com/2006/06/12/javascript-eval-scope-namespace-execution-context/<a>;</LI><br />
<LI>&#8220;The Magic Eval&#8221;, <a href="http://nerd.metrocat.org/2005/09/the-magic-eval">http://nerd.metrocat.org/2005/09/the-magic-eval</a>;</LI><br />
<LI>&#8220;The this keyword&#8221;, <a href="http://www.quirksmode.org/js/this.html">http://www.quirksmode.org/js/this.html</a>;</LI><br />
</LI>&#8220;Javascript Closures&#8221;, <a href="http://www.jibbering.com/faq/faq_notes/closures.html">http://www.jibbering.com/faq/faq_notes/closures.html</a>(note: this is a master piece!);</LI><br />
</OL></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/09/13/javascript-execution-context-closure-eval-and-this-keyword.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/09/13/javascript-execution-context-closure-eval-and-this-keyword.html</feedburner:origLink></item>
		<item>
		<title>Ajax-heavy Applications on Google Chrome</title>
		<link>http://feedproxy.google.com/~r/DirectFromWeb20/~3/jAXnvS2yzcY/ajax-heavy-application-on-google-chrome.html</link>
		<comments>http://www.coachwei.com/blog/2008/09/03/ajax-heavy-application-on-google-chrome.html#comments</comments>
		<pubDate>Wed, 03 Sep 2008 13:02:35 +0000</pubDate>
		<dc:creator>coachwei</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[Ajax]]></category>

		<category><![CDATA[ajax performance]]></category>

		<category><![CDATA[Chrome]]></category>

		<category><![CDATA[razor profiler]]></category>

		<guid isPermaLink="false">http://www.coachwei.com/blog/?p=271</guid>
		<description><![CDATA[&#8220;This is the best browser so far&#8221; is that I can say after being a Chrome user for one day. 
First of all, I was glad to find out that I haven&#8217;t found Chrome breaking any web application yet, especially Ajax applications. I was a little concerned about this, given that the Chrome cartoons say &#8220;Javascript [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;This is the best browser so far&#8221; is that I can say after being a Chrome user for one day. </p>
<p>First of all, I was glad to find out that I haven&#8217;t found Chrome breaking any web application yet, especially Ajax applications. I was a little concerned about this, given that the Chrome cartoons say &#8220;Javascript runs in its own thread&#8221;, which is different from the threading model today. </p>
<p>For example, <a href="http://www.razorspeed.com">Razor Profiler</a> is a fairly Javascript-heavy web application that I wrote to perform JavaScript profiling and Ajax performance analysis. It includes tens of thousands of lines of JavaScript code on the client side, and employs a lot of &#8220;tricks&#8221; to make a web application deliver similar performance characteristics to native applications. -Razor Profiler works well on Chrome. </p>
<p>I also tried a few applications on <a href="http://www.dojotoolkit.org">Dojo</a>, <a href="http://extjs.com">ExtJS</a> and <a href="http://www.jquery.com">jQuery</a>. All worked well without a glitch. </p>
<p>After the initial concern eliminated, now I was able to see the noticeable performance improvement comparing to any other browsers. I am a constant user and tester of Safari, FireFox and IE. Chrome beats any of them hands down. </p>
<p>a. It is clearly faster and smoother to open browser window, close browser window, navigate to new sites, etc on Chrome than any other browser. Chrome delivers a very smooth browsing experience. </p>
<p>b. For Ajax applications, yes, Ajax code runs much faster on Chrome. For example, <a href="http://www.razorspeed.com">Razor Profiler</a>  needs to serialize collected profile data on the client side. There are a lot of data to serialize, typically creating a few hundred kilo-bytes of JSON stream to the server. This serialization process can easily take 5 to 10 seconds on any other browser. On Chrome, the amount of time is probably half of that. </p>
<p>So overall, Chrome is impressive! It certainly raised the bar. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coachwei.com/blog/2008/09/03/ajax-heavy-application-on-google-chrome.html/feed</wfw:commentRss>
		<feedburner:origLink>http://www.coachwei.com/blog/2008/09/03/ajax-heavy-application-on-google-chrome.html</feedburner:origLink></item>
	</channel>
</rss>
