<?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>The Web Development Blog &#187; Website Optimization</title>
	<atom:link href="http://www.thewebdevelopmentblog.com/tag/website-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thewebdevelopmentblog.com</link>
	<description>News, tips, scripts and tutorials for web developers.</description>
	<lastBuildDate>Thu, 25 Aug 2011 11:15:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Speed up your websites using gzip and merging files.</title>
		<link>http://www.thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/</link>
		<comments>http://www.thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 08:07:50 +0000</pubDate>
		<dc:creator>Jason Stockton</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[Gzip]]></category>
		<category><![CDATA[Website Optimization]]></category>

		<guid isPermaLink="false">http://thewebdevelopmentblog.com/?p=95</guid>
		<description><![CDATA[Many sites these days are using more and more Javascript and CSS which can quickly slow the websites loading speed. Gzip compression for your Javascript and CSS is not used in enough websites these days as many people still fear incompatibility with browsers. However this is no longer the case as all modern browsers are [...]]]></description>
			<content:encoded><![CDATA[<p>Many sites these days are using more and more Javascript and CSS which can quickly slow the websites loading speed. Gzip compression for your Javascript and CSS is not used in enough websites these days as many people still fear incompatibility with browsers. However this is no longer the case as all modern browsers are now compatible with it. There are heaps of ways to Gzip, none of which I could get to work on my web host, so I created my own which uses the zlib extension in php. I also included a few advantages to it such as merging of files which helps decrease the loading time even more.</p>
<p><span id="more-95"></span></p>
<h1><strong>Step 1: </strong>Add the gzip.php file.</h1>
<p><a title="Download the gzip.php file and example here." href="http://thewebdevelopmentblog.com/examples/gzip/gzip.zip" target="_self">Download the gzip.php file here. (V1.1.1)</a></p>
<p>Then add it to the root directory of your website.</p>
<h1><strong>Step 2:</strong> Adjust your HTML.</h1>
<p>We now need to set your Javascript and CSS to run through the compression. We do this by adjusting the script and style addresses as follows&#8230;</p>
<p><strong>For CSS</strong></p>
<p><code>&lt;link href="gzip.php?f0=<em>css/main.css</em>" rel="stylesheet" type="text/css"&gt;</code></p>
<p><strong>For Javascript</strong></p>
<p><code>&lt;script src="gzip.php?f0=<em>javascript/main.js</em>" type="text/javascript"&gt;&lt;/script&gt;</code></p>
<p>To change the address of the scripts just change the address that is in italic. Files are restricted to only files with the .css or .js extension.</p>
<h1><strong>Step 3: </strong>Merging Files.</h1>
<p>Another slow point for loading time is using multiple Javascript files and CSS style sheets. The reason for this is for each file the browser needs to re-connect to the server before it can download it. However if you&#8217;re like me, you don&#8217;t want to have to merge all your files into 1 manually, so I&#8217;ve built in this ability into gzip.php. Simply merge files together as follows&#8230;</p>
<p><strong>For CSS</strong></p>
<p><code>&lt;link href="gzip.php?f0=<em>css/main.css</em>&amp;f1=<em>css/more.css</em>&amp;f2=<em>css/evenmore.css</em>" rel="stylesheet" type="text/css"&gt;</code></p>
<p><strong>For Javascript</strong></p>
<p><code>&lt;script src="gzip.php?f0=<em>javascript/main.js</em>&amp;f1=<em>javascript/more.js</em>&amp;f2=<em>javascript/evenmore.js</em>" type="text/javascript"&gt;&lt;/script&gt;</code></p>
<p>So as you can see you can add files by adding in more <em>f</em> variables which count up from 0. You can add up to 100 files in the current configuration. Although if you have that many Javascript or CSS files then you should look at fixing that&#8230;</p>
<p><strong>NOTE: </strong>Make sure you don&#8217;t miss any numbers when counting up otherwise it won&#8217;t include all your files.</p>
<h1><strong>Step 4: </strong>Caching Files.</h1>
<p>Another trick that will help speed up your site is caching these files. Again I have that covered! Simply add <em>cache=true&amp;</em> to the front of the file address as follows&#8230;</p>
<p><code>gzip.php?<em>cache=true&amp;</em>f0=javascript/main.js&amp;f1=javascript/more.js</code></p>
<p>If you don&#8217;t want to have the default 3 days expiry you may add in exp=#ofDays&amp; and it will change the expiry period. For example the following will set the cache period to 31 days&#8230;</p>
<p><code>gzip.php?cache=true&amp;exp=31&amp;f0=javascript/main.js&amp;f1=javascript/more.js</code></p>
<p><strong>NOTE: </strong>It is not recommended that you cache files that are updated frequently as when the file is updated it won&#8217;t update in the browser for the number of days you set.</p>
<p>And there you have it! I have decreased loading time on my sites dramatically using this exact script so I hope it helps you out as much as it has with me!</p>
<p><strong>UPDATE:</strong> Just released version 1.1.1 which adds new functionality and better ways to pinpoint errors. <a title="View Gzip Compression V1.1 Release Notes" href="http://thewebdevelopmentblog.com/examples/gzip/gzip/releasenotes.txt" target="_blank">Release Notes</a>.</p>
<p><strong>UPDATE:</strong> Just released version 1.1 which fixes a security hole (thanks for the heads up Nail) as well as a number of other minor updates. <a title="View Gzip Compression V1.1 Release Notes" href="http://thewebdevelopmentblog.com/examples/gzip/gzip/releasenotes.txt" target="_blank">Release Notes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thewebdevelopmentblog.com/2008/10/tip-speed-up-your-websites-using-gzip-and-merging-files/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
	</channel>
</rss>

