<?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>gHacks technology news &#187; loading time</title>
	<atom:link href="http://www.ghacks.net/tag/loading-time/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ghacks.net</link>
	<description>A technology blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description>
	<lastBuildDate>Wed, 25 Nov 2009 09:43:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Load your advertisements after your content</title>
		<link>http://www.ghacks.net/2009/04/06/load-your-advertisements-after-your-content/</link>
		<comments>http://www.ghacks.net/2009/04/06/load-your-advertisements-after-your-content/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 22:55:05 +0000</pubDate>
		<dc:creator>Daniel Pataki</dc:creator>
				<category><![CDATA[Revenue Sources]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[advertising]]></category>
		<category><![CDATA[delay javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[loading time]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/?p=11700</guid>
		<description><![CDATA[I didn&#8217;t have much use for loading ads after my content, since on most of my sites and those I worked on, they were near the end of the code anyway, but while working on a site today I ran into a problem. There is an ad at the top of the design which tends [...]]]></description>
			<content:encoded><![CDATA[<p>I didn&#8217;t have much use for loading ads after my content, since on most of my sites and those I worked on, they were near the end of the code anyway, but while working on a site today I ran into a problem. There is an ad at the top of the design which tends to load slowly. I have specific requirements that the site should be as fast as possible, so I had to devise a way of loading the ad last. I went through some methods I found online after things off the top of my head didn&#8217;t work, but none helped, so I came up with my own code for it.</p>
<p>I am not taking credit for this, so if you did this before me feel free to let us know, but I did arrive at it on my own. The methods you could try is the &#8220;defer&#8221; attribute, which defers loading to the end of the page load, however, this had no effect at all. You can also try a &#8220;window.onload&#8221;, but this didn&#8217;t help either. With any other function combinations the ad either loaded as usual or did some weird stuff.</p>
<p>In the end, I decided to load the ad at the bottom of the page, right before the &#8220;&#8221; tag, and then use javascript to &#8220;transfer&#8221; the contents to where I need it do be, while keeping the source hidden. This is achieved using the &#8220;document.getElementById&#8221; method, read on to take a look at a specific example.</p>
<p><span id="more-11700"></span></p>
<p>So what we need to do is create a div at the bottom of our page, load the advertisement there, and transfer it to the place we want it to be. I will be using inline CSS and inline javascript, which should not be done in real &#8220;life&#8221;, the best practice is to have all your CSS in external stylsheets and you javascript called from files in the header (where possible). The bottom of our page would look like this:</p>
<p>&lt;div id=&#8221;top_ad_loader&#8221; style=&#8221;display:none;&#8221;&gt;<br />
Ad code in here<br />
&lt;/div&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.getElementById(&#8221;top_ad&#8221;).innerHTML = document.getElementById(&#8221;top_ad_loader&#8221;).innerHTML<br />
&lt;/script&gt;</p>
<p>&lt;/body&gt;</p>
<p>So what is going on here? We have two divs, the first is &#8220;top_ad_loader&#8221;, which you can see right here. This div is hidden, but contains the ad code. When the code is being read, the javascript might take a while to load, but we&#8217;re right at the bottom, so all our content is displayed already. There is also another div, &#8220;top_ad&#8221;, which can not be seen here, it is somewhere way above this part of our code, somewhere near the &#8220;&lt;body&gt;&#8221; tag.</p>
<p>There is javascript code right beneath the ad loader, the purpose of which is to transfer the loaded contents of the ad loader to te place where we want it to be. We &#8220;grab&#8221; the contents inside the ad loader using &#8220;<strong>document.getElementById(&#8221;top_ad_loader&#8221;).innerHTML</strong>&#8220;, and we want the contents of the actual ad block to equal this.</p>
<p>Once the page load gets to the ad it will slowly load it, when finished, parsing will continue, and our javascript will transfer the contents to the top.</p>
<p>If you have a page that loads a bit slowly, perhaps this method would be worth a try? Contents usually load faster than javascript, so if you place the javascript load last your content will load in 1-2 seconds (maybe much less), making the javascript load 1-2 seconds later. However, if a javascript at the beginning loads in 5 seconds, you need to wait that out just to start loading the content.</p>
<p><img class="alignleft size-full wp-image-10878" src="http://www.ghacks.net/wp-content/uploads/2009/03/scrip_twitter.gif" alt="Script" width="53" height="53" /><strong>If you&#8217;d like to read some similar articles, take a look at <a title="Web development blog" href="http://scriptastique.com">Scriptastique</a>, a blog all about web development and coding, with great tips on CSS, HTML, PHP, MySQL and Javascript and tutorials and screencasts coming soon! You can follow us on our <a title="Scriptastique RSS feed" href="http://feeds2.feedburner.com/scriptastique">RSS feed</a>, or <a title="Scriptastique on Twitter" href="http://twitter.com/scriptastique">Twitter</a> where we&#8217;re posting 3-4 short tips daily now!</strong></p>

	Tags: <a href="http://www.ghacks.net/tag/advertising/" title="advertising" rel="tag">advertising</a>, <a href="http://www.ghacks.net/tag/delay-javascript/" title="delay javascript" rel="tag">delay javascript</a>, <a href="http://www.ghacks.net/tag/javascript/" title="javascript" rel="tag">javascript</a>, <a href="http://www.ghacks.net/tag/loading-time/" title="loading time" rel="tag">loading time</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2008/06/27/you-better-stop-using-internet-explorer-for-now/" title="You better stop using Internet Explorer for now (June 27, 2008)">You better stop using Internet Explorer for now</a> (18)</li>
	<li><a href="http://www.ghacks.net/2007/08/08/why-i-disabled-google-analytics-and-wp-cache/" title="Why I disabled Google Analytics and WP-Cache (August 8, 2007)">Why I disabled Google Analytics and WP-Cache</a> (4)</li>
	<li><a href="http://www.ghacks.net/2008/08/19/view-javascript-sources-with-jsview/" title="View Javascript Sources with JSView (August 19, 2008)">View Javascript Sources with JSView</a> (1)</li>
	<li><a href="http://www.ghacks.net/2008/10/17/test-your-browsers-javascript-performance/" title="Test Your Browser&#8217;s JavaScript Performance (October 17, 2008)">Test Your Browser&#8217;s JavaScript Performance</a> (5)</li>
	<li><a href="http://www.ghacks.net/2009/08/16/siteflow-bookmarklet-simplifies-website-navigation/" title="SiteFlow Bookmarklet Simplifies Website Navigation (August 16, 2009)">SiteFlow Bookmarklet Simplifies Website Navigation</a> (3)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2009/04/06/load-your-advertisements-after-your-content/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Why I disabled Google Analytics and WP-Cache</title>
		<link>http://www.ghacks.net/2007/08/08/why-i-disabled-google-analytics-and-wp-cache/</link>
		<comments>http://www.ghacks.net/2007/08/08/why-i-disabled-google-analytics-and-wp-cache/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 20:32:04 +0000</pubDate>
		<dc:creator>Martin</dc:creator>
				<category><![CDATA[The Web]]></category>
		<category><![CDATA[ghacks]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[loading time]]></category>
		<category><![CDATA[page load]]></category>
		<category><![CDATA[speed up site]]></category>
		<category><![CDATA[wp-cache]]></category>

		<guid isPermaLink="false">http://www.ghacks.net/2007/08/08/why-i-disabled-google-analytics-and-wp-cache/</guid>
		<description><![CDATA[I was planing to run some benchmarks on my website with various settings to find a result that would reduce loading time for my website for every visitor. I had one script and one plugin in mind that I wanted to test. The first one was the Google Analytics script which I used to be able to access site statistics on the Google Analytics website while the second was the wp-cache plugin for Wordpress which cached database requests but required that gz compression was disabled which resulted in a larger html file that was transferred to each visitor.]]></description>
			<content:encoded><![CDATA[<p>I was planing to run some benchmarks on my website with various settings to find a result that would reduce loading time for my website for every visitor. I had one script and one plugin in mind that I wanted to test. The first one was the Google Analytics script which I used to be able to access site statistics on the <a href="http://www.google.com/analytics/">Google Analytics</a> website while the second was the <a href="http://mnm.uib.es/gallir/wp-cache-2/">wp-cache</a> plugin for Wordpress which cached database requests but required that gz compression was disabled which resulted in a larger html file that was transferred to each visitor.</p>
<p>I used the free <a href="http://www.websiteoptimization.com/services/analyze/">Web Page Analyzer</a> script to test four settings and compare the results that were shown on the website. I did test the following settings:</p>
<ul>
<li>WP-Cache enabled, Google Analytics off</li>
<li>WP-Cache enabled, Google Analytics on</li>
<li>WP-Cache off, Google Analytics on</li>
<li>WP-Cache off, Google Analytics off</li>
</ul>
<p><span id="more-1848"></span>Let me give you a few instructions about the images below: </p>
<p><strong>Object Type</strong> refers to all files that belong to a certain type such as HTML or CSS files.<br />
<strong>Size</strong> is the total size of all files that belong to a certain type.<br />
<strong>Download T1</strong> the total loading time for a T1 connection (1.54 Mbps) in seconds.</p>
<p>WP-Cache enabled, Google Analytics off:</p>
<p><img src="http://www.ghacks.net/files/screens/2007/08/cacheon-analyticsoff.jpg" alt="wp-cache enabled, google analytics off" /></p>
<p>WP-Cache enabled, Google Analytics on:</p>
<p><img src="http://www.ghacks.net/files/screens/2007/08/cacheon-analyticson.jpg" alt="wp-cache enabled, google analytics on" /></p>
<p>WP-Cache disabled, Google Analytics on:</p>
<p><img src="http://www.ghacks.net/files/screens/2007/08/cacheoff-analyticson.jpg" alt="wp-cache disabled, google analytics on" /></p>
<p>WP-Cache disabled, Google Analytics off:</p>
<p><img src="http://www.ghacks.net/files/screens/2007/08/cacheoff-analyticsoff.jpg" alt="wp-cache disabled, google analytics off" /></p>
<p>The results are quite obvious. Loading time is reduced quite a bit when I turn off WP-Cache and Google Analytics. The total loading time for a T1 connection is 1.86 seconds while it is 2.25 seconds if both options are turned on. </p>
<p>Users with slower connections will see a hugh decrease in total loading time in seconds which is absolutely what I wanted to achieve. There are however two aspects that I have to consider.</p>
<p>Turning off wp-cache reduces the loading time but increases the load on the server because mysql requests are not cached anymore. This could lead to troubles for sites that face lots of visitors, e.g. if your site makes it on the digg frontpage. I would suggest to turn on wp-cache again if that happens to be able to handle the load.</p>
<p>Turning of Google Analytics does not have any negative impact on your site but webmasters with no other statistics script have the problem that they do not have access to their statistics anymore. I&#8217;m using <a href="http://awstats.sourceforge.net/">awstats</a> instead of Google Analytics on my server. If you are unsure contact your webhost and ask which script they are offering.</p>

	Tags: <a href="http://www.ghacks.net/tag/google-analytics/" title="google analytics" rel="tag">google analytics</a>, <a href="http://www.ghacks.net/tag/loading-time/" title="loading time" rel="tag">loading time</a>, <a href="http://www.ghacks.net/tag/page-load/" title="page load" rel="tag">page load</a>, <a href="http://www.ghacks.net/tag/speed-up-site/" title="speed up site" rel="tag">speed up site</a>, <a href="http://www.ghacks.net/tag/wp-cache/" title="wp-cache" rel="tag">wp-cache</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.ghacks.net/2008/08/11/woopra-the-best-free-analytics/" title="Woopra, the best free Analytics (August 11, 2008)">Woopra, the best free Analytics</a> (14)</li>
	<li><a href="http://www.ghacks.net/2009/03/11/statistical-information-about-ghacks-readers/" title="Statistical Information About Ghacks Readers (March 11, 2009)">Statistical Information About Ghacks Readers</a> (15)</li>
	<li><a href="http://www.ghacks.net/2008/08/28/some-interesting-ghacks-visitor-information/" title="Some Interesting Ghacks Visitor Information (August 28, 2008)">Some Interesting Ghacks Visitor Information</a> (7)</li>
	<li><a href="http://www.ghacks.net/2005/11/14/prevent-google-analytics-from-tracking-your-visit/" title="Prevent Google Analytics from tracking your visit (November 14, 2005)">Prevent Google Analytics from tracking your visit</a> (5)</li>
	<li><a href="http://www.ghacks.net/2009/04/06/load-your-advertisements-after-your-content/" title="Load your advertisements after your content (April 6, 2009)">Load your advertisements after your content</a> (6)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ghacks.net/2007/08/08/why-i-disabled-google-analytics-and-wp-cache/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
