<?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: Using setTimeout to Solve DOMContentLoaded?</title>
	<atom:link href="http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Sun, 14 Mar 2010 23:40:55 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ben</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261432</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Mon, 18 Feb 2008 10:22:33 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261432</guid>
		<description>Good suggestion from Peter tbh.
&#124;
function try_again(){
if(document.body){go();}
else{setTimeout(try_again, 1000);}
}
&#124;
Though instead of 1 second, I&#039;d set the timeout on 0.
All browsers have a minimum setTimout timer, which lies between 20ms (fastest afaik) and 75ms (slowest), which should provide nearly the same error margin as other domready methods crossbrowser, though other methods will probably be more accurate for specific browsers.</description>
		<content:encoded><![CDATA[<p>Good suggestion from Peter tbh.<br />
|<br />
function try_again(){<br />
if(document.body){go();}<br />
else{setTimeout(try_again, 1000);}<br />
}<br />
|<br />
Though instead of 1 second, I&#8217;d set the timeout on 0.<br />
All browsers have a minimum setTimout timer, which lies between 20ms (fastest afaik) and 75ms (slowest), which should provide nearly the same error margin as other domready methods crossbrowser, though other methods will probably be more accurate for specific browsers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikael Bergkvist</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261424</link>
		<dc:creator>Mikael Bergkvist</dc:creator>
		<pubDate>Sun, 17 Feb 2008 00:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261424</guid>
		<description>What about 

function try_again(){
if(document.body){go();}
 else{setTimeout(try_again, 1000);}
}</description>
		<content:encoded><![CDATA[<p>What about </p>
<p>function try_again(){<br />
if(document.body){go();}<br />
 else{setTimeout(try_again, 1000);}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PeterMichaux</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261418</link>
		<dc:creator>PeterMichaux</dc:creator>
		<pubDate>Sat, 16 Feb 2008 06:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261418</guid>
		<description>Using the bottom script is too late. If an HTML page stalls half way through the load then it part of it is visible but the elements are not enlivened with the unobtrusive event handlers.

http://peter.michaux.ca/article/3752</description>
		<content:encoded><![CDATA[<p>Using the bottom script is too late. If an HTML page stalls half way through the load then it part of it is visible but the elements are not enlivened with the unobtrusive event handlers.</p>
<p><a href="http://peter.michaux.ca/article/3752" rel="nofollow">http://peter.michaux.ca/article/3752</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Roussey</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261413</link>
		<dc:creator>Steve Roussey</dc:creator>
		<pubDate>Fri, 15 Feb 2008 22:35:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261413</guid>
		<description>@benyc : that is the way you often do it in real life. However, people that create JS libraries have a self imposed limit that all you have to do is include the single  tag, which is easier for adoption of the library.</description>
		<content:encoded><![CDATA[<p>@benyc : that is the way you often do it in real life. However, people that create JS libraries have a self imposed limit that all you have to do is include the single  tag, which is easier for adoption of the library.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benyc</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261411</link>
		<dc:creator>benyc</dc:creator>
		<pubDate>Fri, 15 Feb 2008 21:45:07 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261411</guid>
		<description>What ever happened to just putting a script tag at the bottom of your page and firing your own custom event.  I can&#039;t think of an easier more widely supported method.</description>
		<content:encoded><![CDATA[<p>What ever happened to just putting a script tag at the bottom of your page and firing your own custom event.  I can&#8217;t think of an easier more widely supported method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bollywood</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261404</link>
		<dc:creator>bollywood</dc:creator>
		<pubDate>Fri, 15 Feb 2008 17:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261404</guid>
		<description>Man, jQuery is doing the same.

// Remove event listener to avoid memory leak
			if ( jQuery.browser.mozilla &#124;&#124; jQuery.browser.opera )
				document.removeEventListener( &quot;DOMContentLoaded&quot;, jQuery.ready, false );
			
			// Remove script element used by IE hack
			if( !window.frames.length ) // don&#039;t remove if frames are present (#1187)
				jQuery(window).load(function(){ jQuery(&quot;#__ie_init&quot;).remove(); });</description>
		<content:encoded><![CDATA[<p>Man, jQuery is doing the same.</p>
<p>// Remove event listener to avoid memory leak<br />
			if ( jQuery.browser.mozilla || jQuery.browser.opera )<br />
				document.removeEventListener( &#8220;DOMContentLoaded&#8221;, jQuery.ready, false );</p>
<p>			// Remove script element used by IE hack<br />
			if( !window.frames.length ) // don&#8217;t remove if frames are present (#1187)<br />
				jQuery(window).load(function(){ jQuery(&#8221;#__ie_init&#8221;).remove(); });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: remy</title>
		<link>http://ajaxian.com/archives/using-settimeout-to-solve-domcontentloaded/comment-page-1#comment-261388</link>
		<dc:creator>remy</dc:creator>
		<pubDate>Fri, 15 Feb 2008 13:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3336#comment-261388</guid>
		<description>I just posted this comment on snook.ca (but it&#039;s still waiting moderation).  There&#039;s another problem with using setTimeout - it will fire early if you have slow external scripts on your page.

I&#039;ve put together a simple test that loads an external script which sleeps for a few seconds before responding.  The result, in IE7 + Safari is the setTimeout fires before the DOM is actually ready.

http://remysharp.com/demo/onload.php

So I think if you are going to consider using setTimeout as your DOM ready function, you need to be very sure of the make up of your page, i.e. gzip &amp; no external scripts.  This sounds fine for smaller projects, but doesn&#039;t work so well for companies relying on ads served through JavaScript for some revenue.</description>
		<content:encoded><![CDATA[<p>I just posted this comment on snook.ca (but it&#8217;s still waiting moderation).  There&#8217;s another problem with using setTimeout &#8211; it will fire early if you have slow external scripts on your page.</p>
<p>I&#8217;ve put together a simple test that loads an external script which sleeps for a few seconds before responding.  The result, in IE7 + Safari is the setTimeout fires before the DOM is actually ready.</p>
<p><a href="http://remysharp.com/demo/onload.php" rel="nofollow">http://remysharp.com/demo/onload.php</a></p>
<p>So I think if you are going to consider using setTimeout as your DOM ready function, you need to be very sure of the make up of your page, i.e. gzip &amp; no external scripts.  This sounds fine for smaller projects, but doesn&#8217;t work so well for companies relying on ads served through JavaScript for some revenue.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
