<?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>Midstride Solutions &#187; tips</title>
	<atom:link href="http://blog.midstride.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.midstride.com</link>
	<description>Powerful, simple &#38; easy to use.</description>
	<lastBuildDate>Sat, 18 Apr 2009 20:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>5 tips and tools to optimize your php application &#8211; Part 1 simple</title>
		<link>http://blog.midstride.com/2008/12/01/5-tips-and-tools-to-optimize-your-php-application-part-1-simple/</link>
		<comments>http://blog.midstride.com/2008/12/01/5-tips-and-tools-to-optimize-your-php-application-part-1-simple/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 06:41:26 +0000</pubDate>
		<dc:creator>andre</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[minify]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[yslow]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://blog.midstride.com/?p=33</guid>
		<description><![CDATA[With php becoming a more mature language and frameworks becoming a standard practice, it&#8217;s increasingly important to analyze your code and test the performance where possible.
Frameworks and libraries can speed up the development time and make code maintenance simpler, but it&#8217;s important you understand how they work.  It&#8217;s not just the framework itself but the [...]]]></description>
			<content:encoded><![CDATA[<p>With php becoming a more mature language and frameworks becoming a standard practice, it&#8217;s increasingly important to analyze your code and test the performance where possible.</p>
<p>Frameworks and libraries can speed up the development time and make code maintenance simpler, but it&#8217;s important you understand how they work.  It&#8217;s not just the framework itself but the entire footprint your application leaves when a user visits a specific page.  Ask yourself what&#8217;s involved from the database, to the code/framework, and then to the client through http requests.<br />
<span id="more-33"></span><br />
After experiencing some issues with an application running the Zend Framework, I realized there were a lot of things I was not doing to optimize my application.  There are simple and more complex actions you can take to speed up your application.  Since time is precious, and developers with an expertise on optimization are not always available, I&#8217;ve split this post into two sections (simple and more advanced).  This post focuses on the simple part.</p>
<p><strong>Simple tips and tools<br />
</strong></p>
<ol>
<li><strong>Use Firebug with YSlow<br />
</strong>Firebug and YSlow are powerful tools to analyze the front end of your site.  Run the most common request on your site and see what YSlow says.  Expect a low grade, probably a D or lower.  If you can reach a level C or greater you&#8217;re doing really well as some of the requirements are not practical for most applications.</p>
<blockquote><p>How-to:<br />
<strong>Net</strong>: How many calls are there?  Try to minize these calls and definitely remove any 404 calls as they can eat up server resources.</p>
<p><strong>Console</strong>:  Do you have a lot of POST calls?  Some libraries, like dojo&#8217;s javascript framework, can make a lot of POST requests.  Reduce these if possible.</p>
<p><strong>YSlow</strong>: Rules I would pay attention to:<br />
1. Make fewer HTTP Requests<br />
3. Add an Expires Header<br />
4. Gzip components (server related)<br />
5. Put CSS at the top<br />
6. Put JS at the bottom (not always possible)<br />
7. Avoid CSS expressions<br />
10. Minify JS</p></blockquote>
<p>Resources:<br />
<a href="http://getfirebug.com/">http://getfirebug.com/</a><br />
<a href="http://developer.yahoo.com/yslow/">http://developer.yahoo.com/yslow/</a><br />
<a href="http://developer.yahoo.com/performance/rules.html ">http://developer.yahoo.com/performance/rules.html </a></li>
<li><strong>Minify Javascript and CSS<br />
</strong>Minification is the process of compacting your scripts by removing extraneous content such as white space.   In addition, minification can make attempts at refactoring the code to remove redunancies.  If you want to play it safe, only remove white space to ensure your code is still running. The Yahoo compressor is one of the best minifiers out there and reduces both Javascript and CSS by a significant percentage.</p>
<blockquote><p>How-to:<br />
<strong>java -jar yuicompressor-x.y.z.jar -o style_minified.css style.css</strong></p>
<p>add the &#8220;&#8211;nomunge&#8221; to only do whitespace compressions.</p></blockquote>
<p>Resources:<br />
<a href="http://developer.yahoo.com/yui/compressor/">http://developer.yahoo.com/yui/compressor/</a><br />
<a href="http://dojotoolkit.org/docs/shrinksafe">http://dojotoolkit.org/docs/shrinksafe</a><br />
<a href="http://dean.edwards.name/packer/ ">http://dean.edwards.name/packer/ </a></li>
<li><strong>Merge css and js http requests</strong>- manually or automated<br />
Reduce the amount of calls you make to various CSS and JS files by merging them to one URL.  This is more work but will reduce the overhead.</p>
<blockquote><p>How-to &#8211; manually:<br />
This is really easy, take your css and copy and paste them together into one file.  Make sure your preserve the order of your css.  The same applies to your Javascript files.</p>
<p>How-to &#8211; Automated &#8211; google or your own custom:<br />
Google has a php script which can take various sources and return them as one.</p></blockquote>
<p>Resources:<br />
<a href="http://code.google.com/p/minify/">http://code.google.com/p/minify/</a><br />
<a href="http://reinholdweber.com/?p=37">http://reinholdweber.com/?p=37</a></li>
<li><strong>CSS Background Images are bad &#8211; usually</strong><br />
Using a div for all of your images with a background image is not that great for performance as it requires more calls.  I&#8217;ll be the first to admit it&#8217;s my favourite way to design, but you should try to avoid them where possible.  In addition, for hover states try using one large image with background-position calls to show specific parts.</p>
<blockquote><p>How to:<br />
Use <em><strong><code><span style="color: #000000;">background-position </span></code></strong></em>to select which portion of the large image you want to show.  There isn&#8217;t much more to explain.</p></blockquote>
</li>
<li><strong>GZip<br />
</strong>Gzipping files on the server side will reduce the amount of overhead significantly.  It adds a bit more on the server side, but generally the pay off should be well worth it.</p>
<blockquote><p>How to:<br />
It depends on your server situation, but here&#8217;s a snippet:<br />
mod_gzip_on Yes<br />
mod_gzip_item_include mime ^application/x-javascript$</p>
<p>Refer to <a href="http://snipplr.com/view/9017/gzip-your-components/">http://snipplr.com/view/9017/gzip-your-components/</a> for details</p></blockquote>
<p>Resources:<br />
<a href="http://developer.yahoo.com/performance/rules.html#gzip" target="_blank">http://developer.yahoo.com/performance/rules.html#gzip</a><br />
<a href="http://snipplr.com/view/9017/gzip-your-components/">http://snipplr.com/view/9017/gzip-your-components/</a></li>
</ol>
<p><strong>Conclusion<br />
</strong>That wraps up the simple part of this tutorial&#8230; really, that&#8217;s it!  The focus of these posts is to keep them simple and easy to use.  You may be surprised at how much faster your application runs when you apply these techniques.  I hope you found these useful or at least agree that these are good practices to apply.  In the next part I will examine more advanced methods of optimizing your application.</p>
<p><strong>Feedback<br />
</strong>Your feedback is always appreciated.  In addition to commenting, if you have more resources, please add them to my growing list of links through this buncholink</p>
<p><script src="http://www.buncholinks.com/widget/script/i/162/k/8b5f477e74ec6ed2ad68064aec4034c0" type="text/javascript"></script></p>
<p>It&#8217;s a simple way to organize a group of links together.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/share_save?sitename=Midstride%20Solutions&amp;siteurl=http%3A%2F%2Fblog.midstride.com%2F&amp;linkname=5%20tips%20and%20tools%20to%20optimize%20your%20php%20application%20%E2%80%93%20Part%201%20simple&amp;linkurl=http%3A%2F%2Fblog.midstride.com%2F2008%2F12%2F01%2F5-tips-and-tools-to-optimize-your-php-application-part-1-simple%2F"><img src="http://blog.midstride.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="5 tips and tools to optimize your php application – Part 1 simple";
		a2a_linkurl="http://blog.midstride.com/2008/12/01/5-tips-and-tools-to-optimize-your-php-application-part-1-simple/";
						    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.midstride.com/2008/12/01/5-tips-and-tools-to-optimize-your-php-application-part-1-simple/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
