<?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>gog&#039;s info &#187; Optimization</title>
	<atom:link href="http://gogs.info/category/optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://gogs.info</link>
	<description>&#60;?php echo array_rand(array(&#039;web&#039;, &#039;dev&#039;, &#039;computers&#039;)); ?&#62;</description>
	<lastBuildDate>Fri, 18 Dec 2009 01:23:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Removing require_once() calls from Zend Framework</title>
		<link>http://gogs.info/2008/10/removing-require_once-calls-from-zend-framework/</link>
		<comments>http://gogs.info/2008/10/removing-require_once-calls-from-zend-framework/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 22:39:29 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=44</guid>
		<description><![CDATA[If you are using Zend_Loader to load your classes in Zend Framework, there is no need for all the require_once() calls that are littered all over ZF files.
Some acctually report big improvements in responsiveness of their applications and increase in number of transactions per second their hardware can handle because require_once() is quite an expensive [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <span><span>Zend</span></span>_Loader to load your classes in <span><span>Zend</span></span> Framework, there is no need for all the require_once() calls that are littered all over ZF files.</p>
<p><a href="http://www.whitewashing.de/blog/articles/73">Some <span><span>acctually</span></span> report big improvements</a> in responsiveness of their applications and increase in number of transactions per second their hardware can handle because require_once() is quite an expensive operation, especially if the required file is already included prior to the call.<span id="more-44"></span></p>
<p>If you are wondering how to comment out all the require_once() calls from your <span><span>Zend</span></span> Framework without doing it by hand here is the solution. Navigate to the folder where your installation of ZF resides on the server and just enter this into your shell:</p>
<p><span style="text-decoration: line-through;"><code>find ./ -type f -exec <span><span>sed</span></span> -i 's/require_once/\/\/require_once/' {} \;</code></span></p>
<p>My box is running PHP 5.2.6 with APC 3.0.19 and Zend Framework 1.7 PR and my include path is optimized for use with ZF. Stripping require_once() calls didn&#8217;t make a drastic impact on my setup and average performance gain was around 3 requests per second (from 63 to 66).</p>
<h3>Update (May 16, 2009.)</h3>
<p>Since the release of Zend Framework 1.8 there is a script to strip requre_once calls from ZF in the <a href="http://framework.zend.com/manual/en/performance.classloading.html#performance.classloading.striprequires">ZF Performance guide</a>. This script does not remove require_once calls to the new Zend_Loader_Autoloader component.</p>
<p><code>% cd path/to/ZendFramework/library<br />
% find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' -print0 | \<br />
xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'</code></p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2008/10/removing-require_once-calls-from-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing frontend performance with some Javascript magic</title>
		<link>http://gogs.info/2008/09/optimizing-frontend-performance-with-some-javascript-magic/</link>
		<comments>http://gogs.info/2008/09/optimizing-frontend-performance-with-some-javascript-magic/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 15:52:35 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[openx]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=14</guid>
		<description><![CDATA[So, you know Yahoo!&#8217;s Best Practices for Speeding Up Your Web Site by hart and you have already implemented most of the tips on your web site but you are still not satisfied with the performance bottlenecks caused by your banner serving services (OpenX, formerly known as OpenAds and PhpAdsNew in my case) and other [...]]]></description>
			<content:encoded><![CDATA[<p>So, you know Yahoo!&#8217;s <a href="http://developer.yahoo.com/performance/rules.html">Best Practices for Speeding Up Your Web Site</a> by hart and you have already implemented most of the tips on your web site but you are still not satisfied with the performance bottlenecks caused by your banner serving services (<a href="http://www.openx.org/">OpenX</a>, formerly known as OpenAds and PhpAdsNew in my case) and other stuff you need to use but have no control over it.</p>
<p>Fear no more!</p>
<p><span id="more-14"></span></p>
<p>The idea is not actually mine, so I have to give credit to <a href="http://www.nivas.hr/blog/">Nivas</a> and the post about how they solved the issue. There solution was to load the banner in a hidden div at the end of the page, and use jQuery&#8217;s appendTo() method to move the content to the place the banner is supposed to show. You can read more about their method <a href="http://www.nivas.hr/blog/2008/04/02/trackers-banners-analyzers-and-other-shit-that-slows-down-your-site-but-helps-you-earn-money">here</a>.</p>
<p>The problem (and the reason I&#8217;m writing this post) is that their method has a dependency on jQuery 1.2 (which is the last official build of the jQuery which doesn&#8217;t have problems using this method. Patching jQuery and potentially breaking some other stuff in it wasn&#8217;t really an option.</p>
<p>Since I&#8217;m dependant on the latest jQuery (1.2.6 at the time of the writing) I had to look for some other solution.</p>
<p>Chris Coyier&#8217;s article on <a href="http://css-tricks.com/how-to-fix-video-slowing-down-page-load-time/">How To Fix Video Slowing Down Your Page Load Time</a> gave me an idea. Why don&#8217;t I move the banners invocation code to a separate file and try to work around the appendTo() issues.</p>
<p>So, here it goes:</p>
<ol>
<li>If you are using OpenX for serving your banners, first you have to get the invocation code for your banner (go for iframe version, worked for me).</li>
<li>Put the invocation code into a separate file, let&#8217;s call it <strong>bannerInvocation.html</strong></li>
<li>Create an empty div with an ID (ID&#8217;s need to be unique on the page, but you already knew that) in your HTML that is going to be used as a banner placeholder until we fetch the banner. You can style it, and use a preloader GIF as a background if you like.</li>
<li>Just before the closing &lt;/body&gt; tag insert something like this:<br />
<code>&lt;script type="text/javascript"&gt;<br />
//&lt;![CDATA[<br />
$(window).bind("load", function() {<br />
$('#banner').load('bannerInvocation.html');<br />
});<br />
//]]&gt;<br />
&lt;/script&gt;</code></li>
</ol>
<p>Pros for using this method:</p>
<ol>
<li>Banners start loading only after all other element on the page finished loading, and that includes images as well!</li>
<li>Page loads are faster because important element&#8217;s of the page (images!) don&#8217;t have to compete for bandwidth with ads.</li>
<li>Users can use the site even before the ads load.</li>
</ol>
<p>Cons:</p>
<ol>
<li>You are actually making two extra requests. One to make an AJAX call to the bannerInvocation.html and another one to load the content of the &lt;iframe&gt; that gets loaded from the bannerInvocation.html.</li>
<li>This method requires you to use the jQuery library (or some other JS library for fetching an external file and inserting it into the DOM) and that is a quite an overkill if you don&#8217;t already use the library on your page.</li>
<li>If you are using XHTML strict DTD you are inserting a deprecated element (iframe) into your page. You probably could change the invocation code to use &lt;object&gt; element instead of an &lt;iframe&gt; but AFAIK there are some issues accross different browsers and browser versions in implementing the &lt;object&gt; element.<br />
If it&#8217;s all about the &#8220;<em>look ma, my sites validates using W3C validator, and I can put this cool badge on my site</em>&#8221; don&#8217;t worry. Your page will still show as valid because the iframe gets injected into the DOM via an AJAX call.</li>
</ol>
<p>Of course, you could (and should) set an <a href="http://developer.yahoo.com/performance/rules.html#expires">Expires header</a> for the bannerInvocation.html file so after the first page, the file will be cached into the visitors browser.</p>
<p>If you can think of a better solution, do share. I would really like to see something like this working with the pure JS invocation code for the ads. I really don&#8217;t like iframes, and somethimes they are not an option you can use.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2008/09/optimizing-frontend-performance-with-some-javascript-magic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
