<?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>Rey Bango &#187; Optimization</title>
	<atom:link href="http://blog.reybango.com/category/optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.reybango.com</link>
	<description>JavaScript, HTML, CSS &#38; Random Stuff...</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:46:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Shrinking Your JavaScript Files for Improved Page Performance</title>
		<link>http://blog.reybango.com/2010/06/16/shrinking-your-javascript-files-for-improved-page-performance/</link>
		<comments>http://blog.reybango.com/2010/06/16/shrinking-your-javascript-files-for-improved-page-performance/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 16:28:20 +0000</pubDate>
		<dc:creator>Rey Bango</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://blog.reybango.com/?p=847</guid>
		<description><![CDATA[With all of the performance advances in JavaScript engines in modern browsers, it&#8217;s easy to forget that we still need to do some legwork ourselves, especially considering how many users are still on older browsers. Compressing JavaScript files is an oft forgotten task which could have a dramatic &#038; positive impact and something that will [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>With all of the performance advances in JavaScript engines in modern browsers, it&#8217;s easy to forget that we still need to do some legwork ourselves, especially considering how many users are still on older browsers. Compressing JavaScript files is an oft forgotten task which could have a dramatic &#038; positive impact and something that will make our apps perform better (as well as make <a href="http://stevesouders.com/">Steve Souders</a>, <a href="http://getify.com/">Kyle Simpson</a> &#038; <a href="http://www.nczonline.net/">Nicholas Zakas</a> very happy). <img src='http://blog.reybango.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I used to use the <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> but based on John Resig&#8217;s findings during the release of jQuery 1.4, I&#8217;ve switched to using Google&#8217;s <a href="http://code.google.com/closure/compiler/">Closure Compiler</a> which seems to get better compression.</p>
<h2>Setting Things Up</h2>
<p>It&#8217;s incredibly easy to compress files and I&#8217;m going to outline the steps. The first thing you need to do is <a href="http://java.com/">download Java</a>. Since the Closure Compiler comes in the form of a .jar binary file, you&#8217;ll need Java to run it. Also, I&#8217;d recommended ensuring that you make Java available via your OS path so that you don&#8217;t need some long, convoluted command line statement to get to it.</p>
<p>Next, <a href="http://code.google.com/closure/compiler/">download the Closure Compiler .jar file</a> and drop it into a convenient place that&#8217;s easily accessible.</p>
<p><a href="http://code.google.com/closure/compiler/"><img src="http://blog.reybango.com/wp-content/uploads/2010/06/closure.png" alt="" title="closure" width="575" height="272" class="alignright size-full wp-image-852" /></a></p>
<p>For this tutorial, I&#8217;m going to use the <a href="http://code.jquery.com/jquery-1.4.2.js">uncompressed version of jQuery</a> since it&#8217;s sizeable and will be a good sample to use to demonstrate the results. Uncompressed, that file comes in at 161kb. Note, though, that jQuery already comes packaged in a <a href="http://code.jquery.com/jquery-1.4.2.min.js">compressed, ready-to-use form</a> via the jQuery website and I&#8217;m only using the file for demonstrating file compression.</p>
<h2>Compressing the Code</h2>
<p>Actually compressing the code is incredibly easy. Note that I&#8217;m using Windows so the steps will differ a little if you&#8217;re using OSX with terminal.</p>
<p>Go ahead and click on Start->Run and open a command prompt window by typing in &#8220;CMD&#8221; and hitting Enter. From there, change directories to the directory where you&#8217;ve saved your uncompressed jQuery JavaScript file. If you can&#8217;t remember the DOS command for it, <a href="http://www.computerhope.com/msdos.htm">look up &#8220;CD&#8221;</a> which is the command to allow you to change directories. For example, I need to enter the following to go to my directory:</p>
<p><code>cd \rey\closure</code></p>
<p>Next, run the following command to run the Closure Compiler:</p>
<p>java -jar compiler.jar &#8211;js=jquery-1.4.2.js &#8211;js_output_file=jquery-1.4.2-compressed.js</p>
<p>This will run the compiler and create a new, compressed version of the .js file. The results are immediately obvious:</p>
<p><strong>jQuery Uncompressed: 161kb<br />
jQuery Compresse: 71kb</strong></p>
<p>Shaving off more than 50% of the file size is a REALLY big savings when your users initially come to the site and you want them to get snappy pages.</p>
<h2>Other Choices</h2>
<p>I would highly encourage you to check out the other compressors available to determine which one works for you. In a recent post I made <a href="http://blog.reybango.com/2010/04/29/the-big-list-of-javascript-css-and-html-development-tools-libraries-projects-and-books/">outlining a list of tools I think are really important to client-side development</a>, I mentioned the following:</p>
<p><a href="http://developer.yahoo.com/yui/compressor/">YUI compressor</a><br />
<a href="http://www.crockford.com/javascript/jsmin.html">JSMIN</a><br />
<a href="http://dean.edwards.name/packer/">Dean Edward&#8217;s Packer</a><br />
<a href="http://aspnet.codeplex.com/releases/view/40584">Microsoft Ajax Minifer</a><br />
<a href="http://shrinksafe.dojotoolkit.org/">Dojo Shrinksafe</a></p>
<p>For example, when I ran those tools on the same uncompressed jQuery file, here&#8217;s what I got:</p>
<p>YUI Compressor: 78kb<br />
Microsoft&#8217;s Ajax Minifier: 72kb<br />
Dojo Shrinksafe: 86kb</p>
<p>I tried using Packer and an online version of JSMin but I think the size of the file caused them both to timeout so I don&#8217;t have figures for you.</p>
<p>Again, it&#8217;s important that you do your own homework as there may settings that I&#8217;m not leveraging and could offer even better compression. If you find better performance, let me know. I&#8217;d love to hear about it. </p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.reybango.com/2010/06/16/shrinking-your-javascript-files-for-improved-page-performance/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Holy Compression Batman!</title>
		<link>http://blog.reybango.com/2007/08/23/holy-compression-batman/</link>
		<comments>http://blog.reybango.com/2007/08/23/holy-compression-batman/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 16:26:00 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://www.intoajax.com/index.cfm/2007/8/23/Holy-Compression-Batman</guid>
		<description><![CDATA[So I needed to look into compression techniques for IIS and I decided to enable HTTP compression via IIS. I followed the steps outlined in this article: IIS Compression in IIS6.0 restarted IIS and was COMPLETELY floored by the results. The main page of Gotcfm.com which already was a nice &#038; trim 105k shrunk down [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>So I needed to look into compression techniques for IIS and I decided to enable HTTP compression via IIS.  I followed the steps outlined in this article:</p>
<p><a href="http://www.wwwcoder.com/main/parentid/170/site/3669/68/default.aspx">IIS Compression in IIS6.0</a></p>
<p>restarted IIS and was COMPLETELY floored by the results. The main page of <a href="http://www.gotcfm.com">Gotcfm.com</a> which already was a nice &#038; trim 105k shrunk down to less than half of that!! <strong>It now comes it at a tiny 45k, JS &#038; CSS included! WOAH!!</strong></p>
<p>Now before you run out and go crazy adding compression, be sure to test out your prod code on a dev server. Compression can mess with your files in unexpected ways, especially files that have been previously minified or packed.</p>
<p>Update: So enabling compression somehow messed up my RSS feed for the blog. As soon as I disabled it, the RSS feed worked perfectly. I&apos;ll have to probe this a little further.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.reybango.com/2007/08/23/holy-compression-batman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
