<?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>Ajax Tutorial &#187; gzip</title>
	<atom:link href="http://tutorialajax.com/web/gzip/feed" rel="self" type="application/rss+xml" />
	<link>http://tutorialajax.com</link>
	<description>Prototype, jQuery and another Ajax tutorials</description>
	<lastBuildDate>Tue, 11 Nov 2008 14:24:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compress JavaScript with Gzip</title>
		<link>http://tutorialajax.com/compress-javascript-with-gzip.html</link>
		<comments>http://tutorialajax.com/compress-javascript-with-gzip.html#comments</comments>
		<pubDate>Fri, 07 Nov 2008 18:45:16 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://tutorialajax.com/?p=25</guid>
		<description><![CDATA[The main problem when we are using ajax framework is because of their big size. Of course, it will extremely slow down the sites load time. For example, if we use the standard jQuery, it&#8217;s almost 100Kb. It&#8217;s even more if we use the complete Prototype and Scriptaculous that will cost around 150Kb.
This is really [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The main problem when we are using <a href="http://tutorialajax.com/ajax-framework-basic.html">ajax framework</a> is because of their big size. Of course, it will extremely slow down the sites load time. For example, if we use the standard <a href="http://tutorialajax.com/framework/library/jquery" target="_blank">jQuery</a>, it&#8217;s almost 100Kb. It&#8217;s even more if we use the complete <a href="http://tutorialajax.com/framework/library/prototype">Prototype</a> and <a href="http://script.aculo.us/" target="_blank">Scriptaculous</a> that will cost around 150Kb.</p>
<p>This is really nightmare for people who still use <strong>GPRS</strong> or the old <strong>56kbps Dial-Up</strong> internet connection. It will takes minutes to load the sites or maybe it will takes forever because the browser usually won&#8217;t download it. Unfortunately, it&#8217;s very easy to solve this problem. Do you know that we can compress those files and reduce the size by half or more?<span id="more-25"></span></p>
<p>There are several method to <strong>compress javascript</strong> and I think one of the most efficient method is using <a href="http://www.gzip.org/" target="_blank">Gzip</a> Compression.</p>
<p style="text-align: center;"><img class="aligncenter size-medium wp-image-26" title="gzip" src="http://tutorialajax.com/wp-content/uploads/2008/11/gzip3d.png" alt="Gzip" width="299" height="198" /></p>
<p>To implement the <strong>gzip compression</strong> for websites, first we need to <em>gzip</em> the Javascript files. For that purpose, we will need a gzip-compatible archiver / compressor. <a href="http://www.7-zip.org/" target="_blank">7-zip</a> is my favorite because it&#8217;s small, very fast and it&#8217;s completely free.</p>
<p>Gzip the JavaScript file, change the &#8220;<strong>gz</strong>&#8221; extension to &#8220;<strong>jgz</strong>&#8221; for <strong><em>safari compatibility</em></strong> and upload it to the same location together with the original script. Then next, we must ask apache to get the compressed version if there is available and finally tell the browser to un-compress the file before it can be used.</p>
<p>To do that, we add these following code in our <strong>.htaccess</strong></p>
<p><code>RewriteEngine on<br />
RewriteCond %{HTTP:Accept-Encoding} gzip<br />
RewriteCond %{REQUEST_FILENAME}.jgz -f<br />
RewriteRule (.*)\.js$ $1\.js.jgz [L]<br />
AddType "text/javascript" .js.jgz<br />
AddEncoding gzip .jgz<br />
</code><br />
That&#8217;s all. Yeah.. And if you want to look for another method this is it.:</p>
<ul>
<li><a href="http://joseph.randomnetworks.com/archives/2006/07/13/compressed-javascript/" target="_blank">Joseph Scott’s Blog</a> &#8211; Compressed JavaScript</li>
<li><a href="http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files" target="_blank">rakaz</a> &#8211; Make your pages load faster by combining and compressing javascript and css files</li>
<li><a href="http://www.addedbytes.com/php/php-gzip-and-htaccess/" target="_blank">Added Bytes</a> &#8211; PHP, Gzip and htaccess</li>
<li><a href="http://letmehaveblog.blogspot.com/2007/09/using-gzip-compression-in-web-servers.html" target="_blank">Let me have a blog</a> &#8211; Using GZIP compression in web servers using .HTACCESS</li>
<li><a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html" target="_blank">Apache Module</a> &#8211; mod_deflate</li>
<li><a href="http://sourceforge.net/projects/mod-gzip/" target="_blank">mod_gzip</a> &#8211; Internet Content Acceleration module for the popular Apache Web Server</li>
</ul>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tutorialajax.com/compress-javascript-with-gzip.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

