<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>getiblog &#187; page load</title>
	<atom:link href="http://blog.getify.com/tag/page-load/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.getify.com</link>
	<description>open-source, performance, javascript &#38; ui musings</description>
	<lastBuildDate>Mon, 23 Aug 2010 20:50:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A visual of page-load improvements (via LABjs)</title>
		<link>http://blog.getify.com/2009/12/a-visual-of-page-load-improvements-via-labjs/</link>
		<comments>http://blog.getify.com/2009/12/a-visual-of-page-load-improvements-via-labjs/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 07:21:23 +0000</pubDate>
		<dc:creator>getify</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[UI Architecture]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[labjs]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[page load]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://blog.getify.com/?p=156</guid>
		<description><![CDATA[If you run a website but you&#8217;re not aware of Google&#8217;s free Webmaster Tools, you need to get in the loop! These tools allow you to analyze a number of important aspects of how your site is viewed/analyzed by Google&#8217;s search engine index. 
Yet, with all the power and insight these tools give, it still [...]]]></description>
			<content:encoded><![CDATA[<p>If you run a website but you&#8217;re not aware of Google&#8217;s free <a href="https://www.google.com/webmasters/tools/">Webmaster Tools</a>, you need to get in the loop! These tools allow you to analyze a number of important aspects of how your site is viewed/analyzed by Google&#8217;s search engine index. </p>
<p>Yet, with all the power and insight these tools give, it still feels like it&#8217;s best-kept-secret kind of thing that such tools even exist. I never hear anyone talking or writing about them. But I fire them up probably at least once a month to keep an eye on my various sites.</p>
<p>But the hush-hush of Google&#8217;s toolset makes it more exciting to highlight a really cool addition announced today, the <a href="http://googlewebmastercentral.blogspot.com/2009/12/how-fast-is-your-site.html">new Site Performance tool</a>. True, it&#8217;s still in development and very early on, but it already is showing the promise to give great new insights into how your site is performing out in the wild.</p>
<p>We all got the hint a few weeks ago that <a href="http://searchengineland.com/site-speed-googles-next-ranking-factor-29793">Google is planning</a> to <a href="http://www.downloadsquad.com/2009/11/14/google-to-use-page-load-speed-as-a-search-result-ranking-factor/">start considering page-load speed in its indexing algorithm</a>. It would seem to be somewhat &#8220;evil&#8221; for the world&#8217;s largest search engine to start holding page-load speed against everyone&#8217;s sites without being part of the solution. So it shouldn&#8217;t be a surprise that the G would begin releasing various &#8220;tools&#8221; to help the rest of us actually make our sites load faster. </p>
<h2>Bye, bye, birdie!</h2>
<p>Yesterday, the Google Analytics team released a long-overdue update to their suggested snippet for including &#8220;ga.js&#8221; in pages. They wisely ditched the horrid &#8220;document.write()&#8221; approach that has been the standard for the longest time, in favor of this new <a href="http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html">asynchronous loading</a> technique. The reason? Quite obviously, this now will <strong>unblock</strong> the loading of GA from page loads, thus preventing Google from being at fault for slower load times!</p>
<p><strong>Side Note:</strong> the suggested code that Google has released has been shown not to be safe with all page structures in some browsers, including (ironically!) Chrome, and Opera. The problem is a faulty assumption that &#8220;document.documentElement.firstChild&#8221; will always return a reference to the HEAD element to append the &lt;script> to. As this <a href="http://yura.thinkweb2.com/jstests/document_head_test_by_Garrett.html">documentElement.childNodes test page</a> from <a href="http://twitter.com/kangax">@kangax</a> shows (if loading in Chrome or Opera, for instance), it&#8217;s (too) easy to accidentally create your page in such a way that this assumption will fail. So, be careful before you jump to switching to Google&#8217;s new snippet. (hint: use LABjs instead. Simpler, easier, and much more reliable!)</p>
<p>But, snarkiness aside, the new &#8220;Site Performance&#8221; tool proves its worth when it shows you a graph of your page&#8217;s estimated average load speeds over the last several months, along with a few basic statistics. It also incorporates a number of Google&#8217;s PageSpeed rules and suggestions for how to reduce factors that are slowing down your page loads.</p>
<p>This information is a really great place to start when trying to attack the performance issues your site may have. In fact, it may help you identify issues you didn&#8217;t even know existed!</p>
<h2>Where&#8217;s the visuals?</h2>
<p>Imagine my elation when I pulled up one of my larger, more traffic&#8217;d sites in the tool and saw this graph:</p>
<div id="attachment_157" class="wp-caption aligncenter" style="width: 557px"><img src="http://getiblog.2static.it/wp-content/uploads/2009/12/site-speed.png" alt="Site page-load performance improvements over last few months" title="site-speed" width="547" height="150" class="size-full wp-image-157" /><p class="wp-caption-text">Site page-load performance improvements over last few months</p></div>
<p>I went from an average of over 3.5 seconds per page load back in August down to a current average of less than 0.3 seconds, which the tool claims is better than 98% of sites! Oh, and btw, this site loads over 105k of JS, images, and CSS, so this isn&#8217;t some puny text-only site getting that kind of loading speed. It&#8217;s a testament to the results you can get if you start caring about page-load optimization on many fronts.</p>
<p>But you know the biggest and most obvious change I made back in July and August on the site in question? That&#8217;s right, you guessed it &#8212; that&#8217;s when I first installed early versions of <a href="http://labjs.com">LABjs</a> for all the site&#8217;s scripts. And over time, I&#8217;ve not only improved the efficiency and capabilities of LABjs, but I&#8217;ve also refined more and more how I work to address page load speeds. To be fair, optimizing script loading was only one of many strategies I used, including <a href="http://spriteme.com">CSS spriting</a> and combining/concat&#8217;ing of JS files to reduce the number of HTTP requests.</p>
<p><strong>But it&#8217;s plainly evident that LABjs was a critical part of this process!</strong></p>
<p>No matter what you feel about dynamic script loaders and if they are useful or not, it&#8217;s clear that all of us have to get more serious about improving our page-load performances if we don&#8217;t want to get left in the Google-index dust. I just believe that script loading is an easy and hugely impactful place to start that process. Remember: optimize, optimize, optimize.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.getify.com/2009/12/a-visual-of-page-load-improvements-via-labjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LABjs: new hotness for script loading</title>
		<link>http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading/</link>
		<comments>http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 08:21:06 +0000</pubDate>
		<dc:creator>getify</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[UI Architecture]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[labjs]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[page load]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://blog.getify.com/?p=69</guid>
		<description><![CDATA[What, you mean to tell me you&#8217;re not already loading your scripts with the new hot thing, LABjs?
Just kidding, you&#8217;re probably just now starting to hear about it. But let me tell you, it is the next big thing. I mean, when was the last time someone found a way to completely revamp the plain [...]]]></description>
			<content:encoded><![CDATA[<p>What, you mean to tell me you&#8217;re not already loading your scripts with the new hot thing, <a href="http://labjs.com/">LABjs</a>?</p>
<p>Just kidding, you&#8217;re probably just now starting to hear about it. But let me tell you, it is the <strong>next big thing</strong>. I mean, when was the last time someone found a way to completely revamp the plain ol&#8217; boring &lt;script&gt; tag and give it new life!?</p>
<p>All levity aside, LABjs stands for Loading And Blocking JavaScript. It&#8217;s a general purpose script loader that aims to be able to effectively load any script resource(s), from any location, into any page, at any time. It loads them all as parallel as the browser will allow, but maintains execution order when you express the need to do so in the usage of the API, for keeping dependencies safe.</p>
<p>LABjs&#8217; primary goal is to replace the &#8220;&lt;script&gt; tag soup&#8221; in your pages (you know, all that garbage that clutters up your &lt;head&gt; or the end of your &lt;body&gt;) with a simple and expressive API that gives you complete control over the loading and executing behavior of your scripts.</p>
<p><a href="http://labjs.com/releasenotes.php">LABjs 1.0</a>, just released yesterday, now sports the &#8220;preloading&#8221; feature, which is the culmination of several months of collaborative efforts with <a href="http://stevesouders.com">Steve Souders</a> to bring the best of his script loading work from his most recent book <a href="http://stevesouders.com/efws/links.php?ex#Chapter4">Even Faster Web Sites</a> (EFWS) together with the expressive power of LABjs. We hope the new release represents the best of both worlds, and a really strong, solid solution for loading JavaScript resources into your pages.</p>
<h2>What is &#8220;preloading&#8221; for?</h2>
<p>The primary idea behind the &#8220;preloading&#8221; feature is to &#8220;look ahead&#8221; in the chain of LABjs API calls and start loading all (or, strictly, as many as the browser will allow at a time) scripts at once, but doing so in a &#8220;preloading&#8221; way much like was common years back with preloading images into the cache via JavaScript techniques.</p>
<p>Since the scripts are only preloaded, and not actually executed, LABjs is free to control the execution order of the scripts, which allows it to preserve proper execution order if you use the API functions to express the need to &#8220;wait()&#8221; for dependencies.</p>
<h2>So, how does this improve loading of my page?</h2>
<p>In addition to making the scripts load in parallel with each other (as much as possible), the scripts also load in parallel with the rest of the page&#8217;s resources. This means that virtually all page resources will load at nearly the same time, rather than waiting for one to finish before the next starts, as is common in many current browsers&#8217; implementations of &lt;script&gt; tag behavior.</p>
<div id="attachment_74" class="wp-caption aligncenter" style="width: 660px"><img src="http://getiblog.2static.it/wp-content/uploads/2009/11/figure11.png" alt="FF3, loading scripts serially with each other and page resources. 16.84s" title="FF3 loading resources. 16.84s" width="650" height="96" class="size-full wp-image-74" /><p class="wp-caption-text">FF3, loading scripts serially with each other and page resources. 16.84s</p></div>
<p>Notice how the 3 script files load in succession, and only after they complete do the images start to download (at least <em>those</em> download in parallel!). 16.84 seconds to download serially.</p>
<div id="attachment_84" class="wp-caption aligncenter" style="width: 660px"><img src="http://getiblog.2static.it/wp-content/uploads/2009/11/figure21.png" alt="FF3.5, loading scripts in parallel with each other, but still blocking page resources. 10.69s" title="FF3.5 loading resources. 10.69s" width="650" height="96" class="size-full wp-image-84" /><p class="wp-caption-text">FF3.5, loading scripts in parallel with each other, but still blocking page resources. 10.69s</p></div>
<p>FF3.5 introduced a nice new behavior in that they will download scripts in parallel, but still maintain execution order. So, in this diagram, we see that the scripts are parallel to each other, but still they block other page resources. Down to 10.69 seconds loading all resources.</p>
<div id="attachment_86" class="wp-caption aligncenter" style="width: 660px"><img src="http://getiblog.2static.it/wp-content/uploads/2009/11/figure31.png" alt="LABjs, loading scripts in parallel with each other and other page resources. 6.24s" title="LABjs loading resources (in virtually all browsers)" width="650" height="96" class="size-full wp-image-86" /><p class="wp-caption-text">LABjs, loading scripts in parallel with each other and other page resources. 6.24s</p></div>
<p>This diagram shows the loading behavior of LABjs in <strong>virtually all browsers</strong>, modern and not-so-modern. Notice that not only are scripts loaded in parallel to each other (while still maintaining execution order when necessary), but in parallel with other page resources as well. This means that you can use a much larger slice of the browser&#8217;s bandwidth to grab page resources as quickly as possible, speeding up the loading of the page by significant amounts (generally 2x to 3x speed increase). </p>
<p><strong>In this example, we went from 16.84s down to 6.24s. That&#8217;s a 2.7x speed increase. Now that&#8217;s something to get excited about!</strong><br />
<a name="ux-labjs"></a></p>
<h2>Are there any negative side effects?</h2>
<p>LABjs (and other dynamic script loaders like it) are so good at getting page resources and scripts to load more quickly, it unintentionally creates a lesser seen phenomenon in web user-experience that I am calling &#8220;FUBC&#8221; (flash of un-behaviored content) &#8212; pronounce it &#8220;fubik&#8221; &#8212; which is a takeoff of the more commonly known FOUC (flash of un-styled content).</p>
<p>FUBC means that it is possible that your raw (but still CSS styled) content may arrive to a page and even be displayed momentarily before your JavaScript has had a chance to kick in and attach behaviors or modify it. For some sites, the changes made by JavaScript behaviors are subtle and most users won&#8217;t notice. But for other sites, the &#8220;flash&#8221; between the two views of the content is much more drastic and jarring.</p>
<p>Because this can be a potentially disruptive user-experience, I suggest the following simple steps to address the FUBC phenomenon:</p>
<ol>
<li>
	In your main CSS of your page, hide (display:none or visibility:hidden) all content which will have drastic re-rendering by your JavaScript.
	</li>
<li>
	In your JavaScript, make sure to re-display/unhide the content once it has been styled by your code.
	</li>
<li>
	To take care of users who do not have JavaScript enabled, put a &lt;noscript> block in the &lt;head> of your page that unhides any<br />
	content hidden by your main CSS &#8212; essentially, undo the CSS hiding of content, since there won&#8217;t otherwise be any JavaScript to do so.
	</li>
</ol>
<p>By taking these 3 simple steps, you will effectively address the disruptive FUBC user-experience for JavaScript-enabled users, while still preserving proper display for the non-JavaScript crowd.</p>
<h2>Anything else?</h2>
<p>There are a couple of <a href="http://labjs.com/description.php#whennottouse">minor caveats</a> where LABjs may not be appropriate for your site or scripts. One specifically you should be aware of is the implications of <a href="http://blog.getify.com/2009/11/why-dom-ready-still-sucks/">LABjs with DOM-ready and frameworks like jQuery</a>.</p>
<p>But overall, there are just <a href="http://labjs.com/description.php#whentouse">so many reasons <strong>to</strong> use LABjs</a>. Why not give it a shot, see if helps your page load speed?</p>
<h2>I&#8217;m ready! So how do I use LABjs?</h2>
<p>To start, simply find your nearest &#8220;&lt;script> tag soup&#8221; in a page, and replace it with $LAB API calls, like this:</p>
<p>Old and busted:</p>
<pre style="background-color:#ddd;">
&lt;script src="framework.js">&lt;/script>
&lt;script src="plugin.framework.js">&lt;/script>
&lt;script src="myplugin.framework.js">&lt;/script>
&lt;script src="init.js">&lt;/script>
</pre>
<p>New hotness:</p>
<pre style="background-color:#ddd;">
$LAB
.script("framework.js")<b>.wait()</b>
.script("plugin.framework.js")
.script("myplugin.framework.js")<b>.wait()</b>
.script("init.js");
</pre>
<p>In the above example, all scripts <b>load</b> in parallel (by default). &#8220;framework.js&#8221; needs to execute first, before the others. But &#8220;plugin.framework.js&#8221; and &#8220;myplugin.framework.js&#8221; have no dependencies between them, so their execution order is not important (first-come, first-served). &#8220;init.js&#8221; needs to wait for all 3 scripts to execute before it runs.</p>
<p>The <a href="http://labjs.com/documentation.php#api">LABjs API</a> has a number of other options and alternate usage patterns, so check out the <a href="http://labjs.com/documentation.php">Documentation</a> and the <a href="http://labjs.com/test_suite">Test Suite</a> for more information.</p>
<h2>Responsibility</h2>
<p>I firmly believe it is all our responsibility to do what we can to make the web a better place to live. One of the best ways we can do that is to reduce the amount of time it takes to load friggin&#8217; web pages! So get to it, go <a href="http://labjs.com/download.php">download LABjs</a> right away and give your site a makeover in the &lt;script> tag department!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Content Delivery Network via getiblog.2static.it

Served from: blog.getify.com @ 2010-09-07 20:52:39 -->