<?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: Queue events that occur before JavaScript is loaded</title>
	<atom:link href="http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/</link>
	<description>a blog about building stuff on the web</description>
	<lastBuildDate>Mon, 09 Jan 2012 18:55:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-586</link>
		<dc:creator>Josh Fraser</dc:creator>
		<pubDate>Tue, 30 Jun 2009 19:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-586</guid>
		<description>There&#039;s an interesting article on Ajaxian today that discusses part of this: 
&lt;a href=&quot;http://ajaxian.com/archives/labjs-simple-abstraction-for-loading-dependencies-correctly&quot; target=&quot;_blank&quot;&gt;http://ajaxian.com/archives/labjs-simple-abstract...&lt;/a&gt; </description>
		<content:encoded><![CDATA[<p>There&#039;s an interesting article on Ajaxian today that discusses part of this:<br />
<a href="http://ajaxian.com/archives/labjs-simple-abstraction-for-loading-dependencies-correctly" target="_blank">http://ajaxian.com/archives/labjs-simple-abstract&#8230;</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ToddBurry</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-584</link>
		<dc:creator>ToddBurry</dc:creator>
		<pubDate>Tue, 30 Jun 2009 00:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-584</guid>
		<description>I think it would be really hard. I&#039;ve just been coding in php and was trying to think of some way to make it work like __call, __get, __set, etc. I&#039;ll have to try it out and see what I can come up with. </description>
		<content:encoded><![CDATA[<p>I think it would be really hard. I&#039;ve just been coding in php and was trying to think of some way to make it work like __call, __get, __set, etc. I&#039;ll have to try it out and see what I can come up with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-583</link>
		<dc:creator>Josh Fraser</dc:creator>
		<pubDate>Mon, 29 Jun 2009 17:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-583</guid>
		<description>Is there a way to track it back to know exactly which function caused the error?  It feels like it would be really hard to isolate errors from JS not being loaded from anything else that could happen. </description>
		<content:encoded><![CDATA[<p>Is there a way to track it back to know exactly which function caused the error?  It feels like it would be really hard to isolate errors from JS not being loaded from anything else that could happen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-582</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Mon, 29 Jun 2009 15:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-582</guid>
		<description>Have you tried using the global window.onerror to queue events instead of changing the function names? I guess it might not be easy to support in all browsers and you&#039;d have to have some good regex-fu going. </description>
		<content:encoded><![CDATA[<p>Have you tried using the global window.onerror to queue events instead of changing the function names? I guess it might not be easy to support in all browsers and you&#039;d have to have some good regex-fu going.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-577</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 25 Jun 2009 17:22:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-577</guid>
		<description>Yes this is true.  My main concern with 3rd party scripts is that the end of the first script might not be the end of the necessary JS.  Often remote scripts will then load multiple other objects/scripts that may be necessary for the code to function properly.  And since it&#039;s a remote script, even if this isn&#039;t the case today, it could be tomorrow ;-)  It&#039;s a safe bet if it&#039;s your own JS though that you know when the last bit of JS you need is and can insert it there.  You can even include it as a conditional paramater in the script request if you don&#039;t want it to load all the time.  Like: 
&lt;a href=&quot;http://mydomain.com/js/script.js?callback=true&quot; target=&quot;_blank&quot;&gt;http://mydomain.com/js/script.js?callback=true&lt;/a&gt; 
 
Or something similar, which can then be setup to only include the function call when that parameter is set. </description>
		<content:encoded><![CDATA[<p>Yes this is true.  My main concern with 3rd party scripts is that the end of the first script might not be the end of the necessary JS.  Often remote scripts will then load multiple other objects/scripts that may be necessary for the code to function properly.  And since it&#039;s a remote script, even if this isn&#039;t the case today, it could be tomorrow <img src='http://www.onlineaspect.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   It&#039;s a safe bet if it&#039;s your own JS though that you know when the last bit of JS you need is and can insert it there.  You can even include it as a conditional paramater in the script request if you don&#039;t want it to load all the time.  Like:<br />
<a href="http://mydomain.com/js/script.js?callback=true" target="_blank">http://mydomain.com/js/script.js?callback=true</a> </p>
<p>Or something similar, which can then be setup to only include the function call when that parameter is set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-574</link>
		<dc:creator>Josh Fraser</dc:creator>
		<pubDate>Thu, 25 Jun 2009 14:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-574</guid>
		<description>I like your suggestion of calling dequeue_actions() sooner.  It might get tricky if you are including multiple javascript files in a non-blocking fashion.  If you&#039;re loading them via standard &lt;script&gt; tags it would be simple to add an inline &lt;script&gt;dequeue_actions()&lt;/script&gt; right after your includes even if they&#039;re on different domains.     
   
A more complicated version could easily take an array of scripts to be lazy-loaded and then watch the onload/onreadystatechange for each of them &amp; only call dequeue_actions() once they were all done.  I found some code that would be a great start for anyone interested in taking that on: &lt;a href=&quot;http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/&quot; rel=&quot;nofollow&quot;&gt;http://www.nczonline.net/blog/2009/06/23/loading-...&lt;/a&gt; </description>
		<content:encoded><![CDATA[<p>I like your suggestion of calling dequeue_actions() sooner.  It might get tricky if you are including multiple javascript files in a non-blocking fashion.  If you&#39;re loading them via standard &lt;script&gt; tags it would be simple to add an inline &lt;script&gt;dequeue_actions()&lt;/script&gt; right after your includes even if they&#39;re on different domains.     </p>
<p>A more complicated version could easily take an array of scripts to be lazy-loaded and then watch the onload/onreadystatechange for each of them &amp; only call dequeue_actions() once they were all done.  I found some code that would be a great start for anyone interested in taking that on: <a href="http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/" rel="nofollow">http://www.nczonline.net/blog/2009/06/23/loading-&#8230;</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh Fraser</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-576</link>
		<dc:creator>Josh Fraser</dc:creator>
		<pubDate>Thu, 25 Jun 2009 07:38:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-576</guid>
		<description>Thanks for re-posting this.  That&#039;s a good point about people on slow connections -- although I would argue they&#039;re like IE6 users, they&#039;re already pretty used to having a crappy experience on the web.  :) 
 
When it comes to website performance, it&#039;s usually the perceived speed that matters.  You can have something downloading for a minute behind the scenes and it&#039;s okay as long as the site still *feels* fast. 
 
What about just throwing up a loading indicator when something is added to the queue?  That way you acknowledge the users&#039; action but still keep the perception that the page loaded in 2 seconds... even if we&#039;re still a few seconds away from being truly done.   </description>
		<content:encoded><![CDATA[<p>Thanks for re-posting this.  That&#039;s a good point about people on slow connections &#8212; although I would argue they&#039;re like IE6 users, they&#039;re already pretty used to having a crappy experience on the web.  <img src='http://www.onlineaspect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>When it comes to website performance, it&#039;s usually the perceived speed that matters.  You can have something downloading for a minute behind the scenes and it&#039;s okay as long as the site still *feels* fast. </p>
<p>What about just throwing up a loading indicator when something is added to the queue?  That way you acknowledge the users&#039; action but still keep the perception that the page loaded in 2 seconds&#8230; even if we&#039;re still a few seconds away from being truly done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris G</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-575</link>
		<dc:creator>Chris G</dc:creator>
		<pubDate>Thu, 25 Jun 2009 07:21:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-575</guid>
		<description>elegant, simple solution. for very slow connections, the action queuing may throw people off since nothing happens at first and then everything happens at once. 
 
another solution would be to have javascript links disabled and/or invisible at load time and then write a function that enables them all - but this might be slow for a page with lots of links. better direction would be to disable the css block(s) where the javascript stuff is. it could also display a loading graphic while things are disabled. this would be more seamless but slower for the impatient user. 
 
[reposted from facebook] </description>
		<content:encoded><![CDATA[<p>elegant, simple solution. for very slow connections, the action queuing may throw people off since nothing happens at first and then everything happens at once. </p>
<p>another solution would be to have javascript links disabled and/or invisible at load time and then write a function that enables them all &#8211; but this might be slow for a page with lots of links. better direction would be to disable the css block(s) where the javascript stuff is. it could also display a loading graphic while things are disabled. this would be more seamless but slower for the impatient user. </p>
<p>[reposted from facebook]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.onlineaspect.com/2009/06/24/queue-events-that-occur-before-your-javascript-is-loaded/comment-page-1/#comment-573</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 25 Jun 2009 06:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.onlineaspect.com/?p=307#comment-573</guid>
		<description>Interesting technique.  I&#039;ve not seen this queuing method before, but I have seen another method of dealing w/ this problem that is very similar.  Basically, the idea is that when you load the javascript links initially you give them dummy functions that queue the function call, but then replace the href once the javascript is loaded (and execute the queue).  It avoids the wrapper but at a rather expensive replacement of the links.  I think your idea of a wrapper function is a bit cleaner, but generally eval is pretty bad with large functions/bodies of code in my experience, so the other technique may work better if it&#039;s any more complicated than a straight function call. 
 
One thing you might consider to get a slight bit of extra performance is adding the dequeue_actions(); call to the end of the javascript you&#039;re loading (assuming you control the script and it&#039;s not loaded from a third party).  This will allow the js to execute as soon as the necessary javascript is loaded instead of waiting for the onload event (which on a heavy page could be noticeably later). </description>
		<content:encoded><![CDATA[<p>Interesting technique.  I&#039;ve not seen this queuing method before, but I have seen another method of dealing w/ this problem that is very similar.  Basically, the idea is that when you load the javascript links initially you give them dummy functions that queue the function call, but then replace the href once the javascript is loaded (and execute the queue).  It avoids the wrapper but at a rather expensive replacement of the links.  I think your idea of a wrapper function is a bit cleaner, but generally eval is pretty bad with large functions/bodies of code in my experience, so the other technique may work better if it&#039;s any more complicated than a straight function call. </p>
<p>One thing you might consider to get a slight bit of extra performance is adding the dequeue_actions(); call to the end of the javascript you&#039;re loading (assuming you control the script and it&#039;s not loaded from a third party).  This will allow the js to execute as soon as the necessary javascript is loaded instead of waiting for the onload event (which on a heavy page could be noticeably later).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

