<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: LABjs: new hotness for script loading</title>
	<atom:link href="http://blog.getify.com/labjs-new-hotness-for-script-loading/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/</link>
	<description>javascript, performance, and ui musings</description>
	<lastBuildDate>Mon, 07 May 2012 16:42:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: cam</title>
		<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/comment-page-1/#comment-2319</link>
		<dc:creator>cam</dc:creator>
		<pubDate>Fri, 17 Feb 2012 21:01:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.getify.com/?p=69#comment-2319</guid>
		<description>Thanks for your detailed response. Your post mentioned flash of un-behavioured content and your &lt;code&gt;noscript&lt;/code&gt; solution. I&#039;ve experienced this problem (without using a script loader but just by putting script tags just before the closing body tag) and my solution was to place an inline script immediately after the affected element to hide it. noscript sounds much better.

If I understand your answer correctly, browers must delay DOM-ready when script tags are used because of the risk that scripts contain &lt;code&gt;document.write()&lt;/code&gt;, but using a script loader we can safely load scripts because we know they won&#039;t contain document.write()  (I notice Mozilla says: Never call document.write() from an async script.)

Why is DOM-ready a critical moment in perceived performance? I ask because tags in the HTML before the script tags are rendered before those scripts are run, so if your script tags are just before the closing body tag shouldn&#039;t perceived performance be good? (Sorry if that&#039;s rather a noob question -obviously there&#039;s a good answer to that otherwise we wouldn&#039;t need async and defer and script loaders!)</description>
		<content:encoded><![CDATA[<p>Thanks for your detailed response. Your post mentioned flash of un-behavioured content and your <code>noscript</code> solution. I&#8217;ve experienced this problem (without using a script loader but just by putting script tags just before the closing body tag) and my solution was to place an inline script immediately after the affected element to hide it. noscript sounds much better.</p>
<p>If I understand your answer correctly, browers must delay DOM-ready when script tags are used because of the risk that scripts contain <code>document.write()</code>, but using a script loader we can safely load scripts because we know they won&#8217;t contain document.write()  (I notice Mozilla says: Never call document.write() from an async script.)</p>
<p>Why is DOM-ready a critical moment in perceived performance? I ask because tags in the HTML before the script tags are rendered before those scripts are run, so if your script tags are just before the closing body tag shouldn&#8217;t perceived performance be good? (Sorry if that&#8217;s rather a noob question -obviously there&#8217;s a good answer to that otherwise we wouldn&#8217;t need async and defer and script loaders!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: getify</title>
		<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/comment-page-1/#comment-2318</link>
		<dc:creator>getify</dc:creator>
		<pubDate>Wed, 15 Feb 2012 15:22:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.getify.com/?p=69#comment-2318</guid>
		<description>Great question. Yes, script loaders are still relevant even in the latest generation of browsers. And until we ever get rid of &lt;code&gt;document.write()&lt;/code&gt;, they always will be. Browsers have to assume that a script they are loading *might* contain a &lt;code&gt;document.write()&lt;/code&gt;, because if it does, then it could &quot;change everything&quot;&#8482; It could, for instance, write out a &lt;code&gt;&lt;base&gt;&lt;/code&gt; tag which completely reinterprets all relative resource paths, meaning the browser may have to throw away any look-ahead work it did in downloading those resources, and re-load them.

As such, browsers are forced to, no matter what, hold up the DOM-ready event (that magical moment when a user can interact meaningfully with the page) until it is certain that it in fact DOES know enough about the structure of the page to declare that the &quot;DOM is ready&quot;. This has the effect of blocking DOM-ready until all normally loaded (that is, with &lt;code&gt;&lt;script&gt;&lt;/code&gt; tags) scripts are finished loading and running.

DOM-ready is perhaps the most critical moment in the page&#039;s life time when it comes to both performance and perceived-performance (that is, how fast users FEEL your page is). It&#039;s critical to get DOM-ready to happen as soon as possible. No matter where you load your scripts (top or bottom), if you do so with normal &lt;code&gt;&lt;script&gt;&lt;/code&gt; tags, you will ALWAYS block DOM-ready.

The common wisdom therefore is to use techniques for loading which unblock the DOM-ready from the script load. How can you do so? &lt;code&gt;&lt;script async&gt;&lt;/code&gt; is one such way. The problem is this only works for one script, or for a set of scripts which are entirely independent, because two or more &quot;async&quot; loaded scripts will not execute in any defined order (they execute ASAP).

&lt;code&gt;&lt;script defer&gt;&lt;/code&gt; is the next most common suggestion. However, &quot;defer&quot; is *horribly* buggy. Not only does its behavior differ between browsers if it does or does not block DOM-ready, but there are AWFUL bugs (in IE) where if you load two or more scripts with &quot;defer&quot;, and one of them happens to do something like modify the DOM, it can actually cause that first script to *pause* IN THE MIDDLE OF THE CODE EXECUTION, run another script, then come back to the previous code, causing untold numbers of impossible to track down bugs. Try loading jquery.js and jquery-ui.js, both using &quot;defer&quot;, in IE8 and below, and you&#039;ll see what I mean.

Anyway, bottom line, in most practical cases, &quot;async&quot; and &quot;defer&quot; are simply not good enough.

Ergo, you need a script loader, which gives you the desired behavior (INCLUDING not blocking DOM-ready) without all the bugs. LABjs is, if nothing else, a polyfill for &quot;defer&quot; (and &quot;async&quot; to an extent), to work the way they &quot;ought to&quot;&#8482; work, but never will (because of legacy).</description>
		<content:encoded><![CDATA[<p>Great question. Yes, script loaders are still relevant even in the latest generation of browsers. And until we ever get rid of <code>document.write()</code>, they always will be. Browsers have to assume that a script they are loading *might* contain a <code>document.write()</code>, because if it does, then it could &#8220;change everything&#8221;&trade; It could, for instance, write out a <code>&lt;base></code> tag which completely reinterprets all relative resource paths, meaning the browser may have to throw away any look-ahead work it did in downloading those resources, and re-load them.</p>
<p>As such, browsers are forced to, no matter what, hold up the DOM-ready event (that magical moment when a user can interact meaningfully with the page) until it is certain that it in fact DOES know enough about the structure of the page to declare that the &#8220;DOM is ready&#8221;. This has the effect of blocking DOM-ready until all normally loaded (that is, with <code>&lt;script></code> tags) scripts are finished loading and running.</p>
<p>DOM-ready is perhaps the most critical moment in the page&#8217;s life time when it comes to both performance and perceived-performance (that is, how fast users FEEL your page is). It&#8217;s critical to get DOM-ready to happen as soon as possible. No matter where you load your scripts (top or bottom), if you do so with normal <code>&lt;script></code> tags, you will ALWAYS block DOM-ready.</p>
<p>The common wisdom therefore is to use techniques for loading which unblock the DOM-ready from the script load. How can you do so? <code>&lt;script async></code> is one such way. The problem is this only works for one script, or for a set of scripts which are entirely independent, because two or more &#8220;async&#8221; loaded scripts will not execute in any defined order (they execute ASAP).</p>
<p><code>&lt;script defer></code> is the next most common suggestion. However, &#8220;defer&#8221; is *horribly* buggy. Not only does its behavior differ between browsers if it does or does not block DOM-ready, but there are AWFUL bugs (in IE) where if you load two or more scripts with &#8220;defer&#8221;, and one of them happens to do something like modify the DOM, it can actually cause that first script to *pause* IN THE MIDDLE OF THE CODE EXECUTION, run another script, then come back to the previous code, causing untold numbers of impossible to track down bugs. Try loading jquery.js and jquery-ui.js, both using &#8220;defer&#8221;, in IE8 and below, and you&#8217;ll see what I mean.</p>
<p>Anyway, bottom line, in most practical cases, &#8220;async&#8221; and &#8220;defer&#8221; are simply not good enough.</p>
<p>Ergo, you need a script loader, which gives you the desired behavior (INCLUDING not blocking DOM-ready) without all the bugs. LABjs is, if nothing else, a polyfill for &#8220;defer&#8221; (and &#8220;async&#8221; to an extent), to work the way they &#8220;ought to&#8221;&trade; work, but never will (because of legacy).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cam</title>
		<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/comment-page-1/#comment-2317</link>
		<dc:creator>cam</dc:creator>
		<pubDate>Wed, 15 Feb 2012 14:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.getify.com/?p=69#comment-2317</guid>
		<description>I&#039;ve opened the developer tools network tab in both Chrome 16 and Firefox 7 on &lt;a href=&quot;http://stevesouders.com/cuzillion/?c0=bj1hfff2_0_f&amp;c1=bj1hfff2_0_f&amp;c2=bj1hfff2_0_f&amp;c3=bj1hfff2_0_f&amp;c4=bi1hfff2_0_f&amp;c5=bi1hfff2_0_f&amp;t=1329243656621&quot; rel=&quot;nofollow&quot;&gt;a Cuzillion test page&lt;/a&gt; and both appear to show scripts and images being downloaded -all in parallel.

I&#039;ve read (and you mention FF3.5 here) that newer browsers can download scripts that are referenced in script tags in parallel with each other. But what this seems to show is even newer browsers actually downloading scripts in parallel with other resources like images.

Is LABjs still needed? (or is it still worth using for when a user has an older browser?) 

I might just be confused: with http://labjs.com/test_suite/test-script-tags.php Chrome 16 developers tools shows images being downloaded only after the scripts are downloaded. That said, in this case the script tags are in the document&#039;s head whereas with the Cuzillion example they are in the body.

Putting older browsers aside for a moment, is LABjs only relevant if you need to put your scripts in the document&#039;s head? 

Thanks for any thoughts</description>
		<content:encoded><![CDATA[<p>I&#8217;ve opened the developer tools network tab in both Chrome 16 and Firefox 7 on <a href="http://stevesouders.com/cuzillion/?c0=bj1hfff2_0_f&amp;c1=bj1hfff2_0_f&amp;c2=bj1hfff2_0_f&amp;c3=bj1hfff2_0_f&amp;c4=bi1hfff2_0_f&amp;c5=bi1hfff2_0_f&amp;t=1329243656621" rel="nofollow">a Cuzillion test page</a> and both appear to show scripts and images being downloaded -all in parallel.</p>
<p>I&#8217;ve read (and you mention FF3.5 here) that newer browsers can download scripts that are referenced in script tags in parallel with each other. But what this seems to show is even newer browsers actually downloading scripts in parallel with other resources like images.</p>
<p>Is LABjs still needed? (or is it still worth using for when a user has an older browser?) </p>
<p>I might just be confused: with <a href="http://labjs.com/test_suite/test-script-tags.php" rel="nofollow">http://labjs.com/test_suite/test-script-tags.php</a> Chrome 16 developers tools shows images being downloaded only after the scripts are downloaded. That said, in this case the script tags are in the document&#8217;s head whereas with the Cuzillion example they are in the body.</p>
<p>Putting older browsers aside for a moment, is LABjs only relevant if you need to put your scripts in the document&#8217;s head? </p>
<p>Thanks for any thoughts</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali&#39;s Surprisingly Web &#187; LABjs â€“ Efektif DÄ±ÅŸ Kaynak YÃ¼klemesi</title>
		<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/comment-page-1/#comment-286</link>
		<dc:creator>Ali&#39;s Surprisingly Web &#187; LABjs â€“ Efektif DÄ±ÅŸ Kaynak YÃ¼klemesi</dc:creator>
		<pubDate>Thu, 15 Jul 2010 13:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.getify.com/?p=69#comment-286</guid>
		<description>[...] saÄŸlamÄ±ÅŸ oluyor. Konuyla ilgili detaylÄ± bir incelemeyi (resimleri da aldÄ±ÄŸÄ±m kaynak olan) http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading adresinden [...]</description>
		<content:encoded><![CDATA[<p>[...] saÄŸlamÄ±ÅŸ oluyor. Konuyla ilgili detaylÄ± bir incelemeyi (resimleri da aldÄ±ÄŸÄ±m kaynak olan) <a href="http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading" rel="nofollow">http://blog.getify.com/2009/11/labjs-new-hotness-for-script-loading</a> adresinden [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Perini</title>
		<link>http://blog.getify.com/labjs-new-hotness-for-script-loading/comment-page-1/#comment-28</link>
		<dc:creator>Diego Perini</dc:creator>
		<pubDate>Tue, 01 Dec 2009 18:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.getify.com/?p=69#comment-28</guid>
		<description>Kyle,
I am really impressed by the work you did and the gains in the graphs.

I had an &#039;iframe&#039; parallel loading implementation but it&#039;s not working for the damn IE, so not usable on more than the 60% of browsers around ;-)

Your solution is quite appealing since it seems easy to implement on most sites and working cross-browser. My compliments.</description>
		<content:encoded><![CDATA[<p>Kyle,<br />
I am really impressed by the work you did and the gains in the graphs.</p>
<p>I had an &#8216;iframe&#8217; parallel loading implementation but it&#8217;s not working for the damn IE, so not usable on more than the 60% of browsers around <img src='http://getiblog.2static.it/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Your solution is quite appealing since it seems easy to implement on most sites and working cross-browser. My compliments.</p>
]]></content:encoded>
	</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 @ 2012-05-18 08:47:51 -->
