<?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>fforw.de &#187; gzip</title>
	<atom:link href="http://fforw.de/tag/gzip/feed/" rel="self" type="application/rss+xml" />
	<link>http://fforw.de</link>
	<description>skip the boring parts</description>
	<lastBuildDate>Fri, 10 Sep 2010 16:32:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Javascript Slim-Down</title>
		<link>http://fforw.de/post/javascript-slim-down/</link>
		<comments>http://fforw.de/post/javascript-slim-down/#comments</comments>
		<pubDate>Mon, 24 Jul 2006 20:09:26 +0000</pubDate>
		<dc:creator>fforw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[turbogears]]></category>

		<guid isPermaLink="false">http://blog.willie/?p=18</guid>
		<description><![CDATA[Modern javascript libraries tend to be fat. This increases the page load latency, wastes bandwidth and is a real problem for people with slower connections (There are still about 50% dialup users). So trying to slim things down comes almost naturally. In this article I will try to present two compression methods that together will [...]]]></description>
			<content:encoded><![CDATA[<p>Modern javascript libraries tend to be <strong>fat</strong>. This increases the page load latency, wastes bandwidth and is a real problem for people with slower connections (There are still about 50% dialup users). So trying to slim things down comes almost naturally.</p>
<p>In this article I will try to present two compression methods that together will make your scripts lose up to 80% of their weight and I will also present an alternative way to serve gzip compressed files with <a href="http://www.turbogears.org" title="Turbogears home page">Turbogears</a> : a precompressing gzip controller for Turbogears.  </p>
<hr width="100%" size="2" />
<p>The first thing one can do is <a href="/post/Dojo_Javascript_Compression_and_IE_conditional_compilation/" title="fforw.de post: Dojo Javascript Compression and IE conditional compilation">javascript compression</a>. Stripping unnecessary whitespace and renaming local variables can already bring down the size a bit, The <a href="http://dojotoolkit.org/docs/compressor_system.html">dojo javascript compressor</a> ( <a href="http://alex.dojotoolkit.org/shrinksafe/">online version</a>  ) does both.</p>
<p>Let&#8217;s take two of the javascript libraries used for this site as examples:</p>
<ul>
<li><em>ff-src.js</em> &#8211; source version of my own javascript library </p>
<p>Uncompressed: 10.1 KB<br />Javascript compressed: 6.7 KB<br /><strong>Compression: 33%</p>
<p></strong></li>
<li><em>tinymce.js</em> &#8211; all sources I need from the <a href="http://tinymce.moxiecode.com/" title="tinymce home page">tinymce richtext editor</a> joined together
<p>Uncompressed: 329.0 KB<br />Javascript compressed: 233.6 KB<br /><strong>Compression:</strong> 29%</li>
</ul>
<p>This sure is nice for a start, but we can go even one step further with gzip compression. Gzip compression is a w3 standard ( defined in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616</a> ) and can be used to send the output of a server compressed to a client. Using this our files shrink even more: </p>
<ul>
<li><em>ff-src.js</em><br />Uncompressed: 10.1 KB<br />Js and gzip compressed : 2.8 KB<br /><strong>Compression:</strong> 73%</li>
<li><em>tinymce.js</em><br />Uncompressed: 329.0 KB<br />Js and gzip compressed : 57.8 KB<br /><strong>Compression:</strong> 82%</li>
</ul>
<p>Most modern web servers allow you to enable general gzip compression. IIS does it, Apache has mod_gzip for it, Turbogears can do gzip compression via <a href="http://www.cherrypy.org/wiki/GzipFilter">cherrypy&#8217;s gzip filter</a>. </p>
<p>Personally this felt like an overkill to me. I don&#8217;t really want to use my precious server CPU cycles to compress output where it&#8217;s no larger win to do so. So I wrote myself a precompressing gzip controller for <a href="http://www.turbogears.org" title="Turbogears home page">Turbogears</a>. It creates gzipped copies of a configurable set of files and automatically updates them. If the client browser supports gzip encoding, the gzipped file copy is sent, otherwise the normal file is send.</p>
<p>The controller is meant to be used as a subcontroller list this</p>
<blockquote><p>class Root( controllers.RootController ):<br />    # subcontroller<br />    gz = GzipController()</p></blockquote>
<p> This would map the gzip controller to <em>/gz/ .</em></p>
<p><u><strong>Download:</strong></u></p>
<ul>
<li> <a href="/static/files/gz.py" title="gzip controller source">gz.py</a>  &#8212; precompressing gzip controller </li>
<li><u>serveFile.patch</u>  &#8212; Update: the patch has been integrated into the turbogears distribution</li>
</ul>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://fforw.de/post/javascript-slim-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
