<?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>潔靜精微 &#187; compressor</title>
	<atom:link href="http://julabs.me/blog/tags/compressor/feed/" rel="self" type="application/rss+xml" />
	<link>http://julabs.me/blog</link>
	<description>想努力创造完美的东西，必须具备心灵的纯洁，同时富于宗教精神。</description>
	<lastBuildDate>Wed, 18 Jan 2012 06:34:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>JavaScript压缩工具</title>
		<link>http://julabs.me/blog/tools-for-javascript-compressor/</link>
		<comments>http://julabs.me/blog/tools-for-javascript-compressor/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 15:53:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[compressor]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=263</guid>
		<description><![CDATA[JavaScript压缩工具很多，常用的可能就是YUICompressor、Closure Compiler、Packer，但我最常用的还是YUICompressor。 YUICompressor YUICompressor是建立在rhino interpreter基础上的，所以它的特点就是安全。YUICompressor是用Java编写的，要运行它首先要配置好Java环境。YUICompressor的压缩内容如下： 移除注释 移除额外的空格 细微优化 标识符替换（Identifier Replacement） 使用YUICompressor的命令行代码如下： java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js --charset utf-8 YUICompressor在压缩时还能够自动检查JS代码是否有错误，如果有错误它会列出错误的行数和原因。更难得的是，它也可以压缩CSS文件，对于前端人员简直就是一把多功能的瑞士军刀。 淘宝UED部把YUICompressor封装成了TBCompressor，这里有篇《TBCompressor介绍》，使用TBCompressor更加简单快捷。 Closure Compiler Closure Compiler是Google公司公布的一款JS压缩工具，和YUICompressor相比，它的压缩率稍微高点，只是稍微，但对代码的准确率要求更高点。这里有一篇LifeSinger整理的《Closure Compiler vs YUICompressor》，讲述了两者的异同，可以做为选择的一个参考。 Closure Compiler使用的命令行代码如下： java -jar compiler.jar --js hello.js --js_output_file hello-compiled.js Closure Compiler还不仅提供了一个网络版可以直接在网页上压缩，而且还开放了API，你可以用HTML、Python或者其它语言文件调用这个API来压缩JS文件。 Packer &#8230; <a href="http://julabs.me/blog/tools-for-javascript-compressor/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JavaScript压缩工具很多，常用的可能就是<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>、<a href="http://code.google.com/intl/zh-CN/closure/compiler/" target="_blank">Closure Compiler</a>、<a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a>，但我最常用的还是<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>。</p>
<h4><a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a></h4>
<p><a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>是建立在<a href="http://www.mozilla.org/rhino/" target="_blank">rhino interpreter</a>基础上的，所以它的特点就是<strong>安全</strong>。<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>是用<a href="http://www.java.com/zh_CN/" target="_blank">Java</a>编写的，要运行它首先要配置好<a href="http://www.java.com/zh_CN/" target="_blank">Java</a>环境。<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>的压缩内容如下：</p>
<ul>
<li>移除注释</li>
<li>移除额外的空格</li>
<li>细微优化</li>
<li>标识符替换（Identifier Replacement）</li>
</ul>
<p>使用<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>的命令行代码如下：</p>
<pre><code class="dos">java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js --charset utf-8</code></pre>
<p><a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>在压缩时还能够自动检查JS代码是否有错误，如果有错误它会列出错误的行数和原因。更难得的是，它也可以压缩<abbr title="Cascading Style Sheets">CSS</abbr>文件，对于前端人员简直就是一把多功能的瑞士军刀。</p>
<p><a href="http://ued.taobao.com/" target="_blank">淘宝UED部</a>把<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>封装成了<a href="http://lifesinger.org/blog/2009/02/tbcompressor-242/" target="_blank">TBCompressor</a>，这里有篇<a href="http://julabs.me/blog/soft/tbcompressor-intro/" target="_blank">《TBCompressor介绍》</a>，使用<a href="http://lifesinger.org/blog/2009/02/tbcompressor-242/" target="_blank">TBCompressor</a>更加简单快捷。</p>
<h4><a href="http://code.google.com/intl/zh-CN/closure/compiler/" target="_blank">Closure Compiler</a></h4>
<p><a href="http://code.google.com/intl/zh-CN/closure/compiler/" target="_blank">Closure Compiler</a>是Google公司公布的一款JS压缩工具，和<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUICompressor</a>相比，它的压缩率稍微高点，只是稍微，但对代码的准确率要求更高点。这里有一篇<a href="http://lifesinger.org/blog/" target="_blank">LifeSinger</a>整理的<a href="http://www.slideshare.net/lifesinger/closure-compiler-vs-yuicompressor" target="_blank">《Closure Compiler vs YUICompressor》</a>，讲述了两者的异同，可以做为选择的一个参考。</p>
<p><a href="http://code.google.com/intl/zh-CN/closure/compiler/" target="_blank">Closure Compiler</a>使用的命令行代码如下：</p>
<pre><code class="dos">java -jar compiler.jar --js hello.js --js_output_file hello-compiled.js</code></pre>
<p><a href="http://code.google.com/intl/zh-CN/closure/compiler/" target="_blank">Closure Compiler</a>还不仅提供了一个<a href="http://closure-compiler.appspot.com/home" target="_blank">网络版</a>可以直接在网页上压缩，而且还开放了<a href="http://code.google.com/intl/zh-CN/closure/compiler/docs/api-tutorial1.html" target="_blank">API</a>，你可以用HTML、Python或者其它语言文件调用这个API来压缩JS文件。</p>
<h4><a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a></h4>
<p><a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a>是目前压缩率最高的JavaScript压缩工具，由<a href="http://dean.edwards.name/" target="_blank">Dean Edwards</a>创建的。压缩后的JavaScript文件相当于一个ZIP文件，在执行的时候能够自动解压。不过带来的副作用就是对于编写不严格的代码，压缩时会出错，可以在压缩前用<a href="http://www.jslint.com/" target="_blank">JSMin</a>检查下。虽然<a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a>压缩后的代码在执行时先要自解压下，会降低执行效率，但对于大型文件来说，<a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a>的压缩率通常能达到50%，因而能加快下载速度。</p>
<p><a href="http://dean.edwards.name/download/#packer" target="_blank">Packer</a>不仅有<a href="http://dean.edwards.name/packer/" target="_blank">网页版</a>，还有<a href="http://dean.edwards.name/download/#packer" target="_blank">.NET、perl和PHP版</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/tools-for-javascript-compressor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>介绍一个CSS压缩网站</title>
		<link>http://julabs.me/blog/cleancss-intro/</link>
		<comments>http://julabs.me/blog/cleancss-intro/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 10:31:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[cleancss]]></category>
		<category><![CDATA[compressor]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=126</guid>
		<description><![CDATA[cleancss是一个免费提供CSS代码格式化和优化服务的网站，它的压缩能力很强。 在“CSS Input”栏中输入所要压缩的CSS代码，点击“Process CSS”按钮就能在页面的最下方找到压缩过后的CSS代码了。 “Code Layout”栏中是它的选项，第一个选项是代码压缩级，有五个选项： Highest (no readability, smallest size)：最高级压缩，可读性非常差，但是体积最小； High (moderate readability, smaller size)：高级压缩，可读性差，体积小； Standard (balance between readability and size)：标准压缩，可读性不错； Low (higher readability)：低级压缩，可读性强； Custom (enter below) ：用户自定义。 以上五个选项中Highest（最高级压缩）的体积最小，甚至比自己手动写的代码体积还要小，不过在使用前最好还是检查一下。它的下面还有很多选项，就不一一列举了，不过个人认为只要按照它默认的设置压缩就可以了，压缩的有关信息可以在“Messages”栏中获得。]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cleancss.com/" target="_blank" title="clean css" class="img"><img src="http://www.cleancss.com/images/cleancss.jpg" alt="cleancss" width="350" height="84" border="0" /></a><a href="http://www.cleancss.com/" target="_blank" title="cleancss">cleancss</a>是一个免费提供CSS代码格式化和优化服务的网站，它的压缩能力很强。</p>
<p>在“CSS Input”栏中输入所要压缩的CSS代码，点击“Process CSS”按钮就能在页面的最下方找到压缩过后的CSS代码了。</p>
<p>“Code Layout”栏中是它的选项，第一个选项是代码压缩级，有五个选项：</p>
<ul>
<li>Highest (no readability, smallest size)：最高级压缩，可读性非常差，但是体积最小；</li>
<li>High (moderate readability, smaller size)：高级压缩，可读性差，体积小；</li>
<li>Standard (balance between readability and size)：标准压缩，可读性不错；</li>
<li>Low (higher readability)：低级压缩，可读性强；</li>
<li>Custom (enter below) ：用户自定义。</li>
</ul>
<p>以上五个选项中Highest（最高级压缩）的体积最小，甚至比自己手动写的代码体积还要小，不过在使用前最好还是检查一下。它的下面还有很多选项，就不一一列举了，不过个人认为只要按照它默认的设置压缩就可以了，压缩的有关信息可以在“Messages”栏中获得。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/cleancss-intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TBCompressor介绍</title>
		<link>http://julabs.me/blog/tbcompressor-intro/</link>
		<comments>http://julabs.me/blog/tbcompressor-intro/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 09:17:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[compressor]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=81</guid>
		<description><![CDATA[公司原先的JS和CSS文件都是用在线压缩程序压缩的，看似方便，但很容易出错，可能是压缩程序把CSS里面的一些Hack语句给混淆了，于是我决定用大名鼎鼎的YUI compressor。 但YUI compressor也有一个缺点，那就是操作不人性化，要用输入命令行的方式进行操作，在实际应用中也有点不方便。今天发现了淘宝人开发的一个软件——TBCompressor，这个软件是在YUI compressor的基础上改进的，使用十分简单,详情请看lifesinger的《TBCompressor – JS和CSS压缩工具》一文。下面是TBCompressor的使用方法，下载请到http://code.google.com/p/ourtools/downloads/list下载，选择里面的yuicompressor_2.4.2.zip文件。 解压后点击里面的install.cmd安装，如果卸载点击uninstall.cmd就可以了； 在要压缩的JS文件或者CSS文件上点击右键，在弹出的菜单中选择Process with YUICompressor； 在原文件同一目录下会生成一个已经被压缩后的文件，文件名就是原文件名后面加个“-min”。比如原文件名为“test.js”，那么压缩后的文件就是“test-min.js”。建议把文件名取成name.source.js类型的，它会自动压缩生成name.js文件。 注意：TBCompressor默认压缩文件的编码类型为GB18030，如果要压缩其它编码类型的文件就修改下安装目录下的compressor.cmd文件，把里面的GB18030替换为你要的编码类型就可以了。比如我用的是UTF8，就把GB18030改成utf-8就行了。TBCompressor的压缩率并不是太高，但是却十分安全，对于CSS文件的Hack也能很好的保留。如果你是个对代码有洁癖的人，也可以利用己压缩的文件再优化。 下面再介绍一些在线优化JS和CSS的网站，不过这些经过压缩的代码在运行时可能会出错，所以在使用时要谨慎： http://javascriptcompressor.com/ http://www.xmlforasp.net/JSCompressor.aspx http://compressorrater.thruhere.net/ http://jsbeautifier.org/ http://www.codebeautifier.com/ http://www.lonniebest.com/FormatCSS/ http://www.cssdrive.com/index.php/main/csscompressor/ http://tools.arantius.com/css-compressor]]></description>
			<content:encoded><![CDATA[<p>公司原先的JS和CSS文件都是用在线压缩程序压缩的，看似方便，但很容易出错，可能是压缩程序把CSS里面的一些Hack语句给混淆了，于是我决定用大名鼎鼎的<a href="http://yuilibrary.com/downloads/" target="_blank">YUI compressor</a>。</p>
<p>但<a href="http://yuilibrary.com/downloads/" target="_blank">YUI compressor</a>也有一个缺点，那就是操作不人性化，要用输入命令行的方式进行操作，在实际应用中也有点不方便。今天发现了淘宝人开发的一个软件——<a href="http://code.google.com/p/ourtools/downloads/list" target="_blank">TBCompressor</a>，这个软件是在<a href="http://yuilibrary.com/downloads/" target="_blank">YUI compressor</a>的基础上改进的，使用十分简单,详情请看<a href="http://lifesinger.org/blog/" target="_blank">lifesinger</a>的<a href="http://lifesinger.org/blog/2008/10/tbcompressor-240/" target="_blank">《TBCompressor – JS和CSS压缩工具》</a>一文。下面是<a href="http://code.google.com/p/ourtools/downloads/list" target="_blank">TBCompressor</a>的使用方法，下载请到<a href="http://code.google.com/p/ourtools/downloads/list" target="_blank">http://code.google.com/p/ourtools/downloads/list</a>下载，选择里面的<strong>yuicompressor_2.4.2.zip</strong>文件。</p>
<ol>
<li>解压后点击里面的<strong>install.cmd</strong>安装，如果卸载点击<strong>uninstall.cmd</strong>就可以了；</li>
<li>在要压缩的JS文件或者CSS文件上点击右键，在弹出的菜单中选择<strong>Process with YUICompressor</strong>；</li>
<li>在原文件同一目录下会生成一个已经被压缩后的文件，文件名就是原文件名后面加个“<strong>-min</strong>”。比如原文件名为“<strong>test.js</strong>”，那么压缩后的文件就是“<strong>test-min.js</strong>”。建议把文件名取成<strong>name.source.js</strong>类型的，它会自动压缩生成<strong>name.js</strong>文件。</li>
</ol>
<p>注意：<a href="http://code.google.com/p/ourtools/downloads/list" target="_blank">TBCompressor</a>默认压缩文件的编码类型为<strong>GB18030</strong>，如果要压缩其它编码类型的文件就修改下安装目录下的<strong>compressor.cmd</strong>文件，把里面的<strong>GB18030</strong>替换为你要的编码类型就可以了。比如我用的是<strong>UTF8</strong>，就把<strong>GB18030</strong>改成<strong>utf-8</strong>就行了。<a href="http://code.google.com/p/ourtools/downloads/list" target="_blank">TBCompressor</a>的压缩率并不是太高，但是却十分安全，对于CSS文件的Hack也能很好的保留。如果你是个对代码有洁癖的人，也可以利用己压缩的文件再优化。</p>
<p>下面再介绍一些在线优化JS和CSS的网站，不过这些经过压缩的代码在运行时可能会出错，所以在使用时要谨慎：</p>
<ul>
<li><a href="http://javascriptcompressor.com/" target="_blank">http://javascriptcompressor.com/</a></li>
<li><a href="http://www.xmlforasp.net/JSCompressor.aspx" target="_blank">http://www.xmlforasp.net/JSCompressor.aspx</a></li>
<li><a href="http://compressorrater.thruhere.net/" target="_blank">http://compressorrater.thruhere.net/</a></li>
<li><a href="http://jsbeautifier.org/" target="_blank">http://jsbeautifier.org/</a></li>
<li><a href="http://www.codebeautifier.com/" target="_blank">http://www.codebeautifier.com/</a></li>
<li><a href="http://www.lonniebest.com/FormatCSS/" target="_blank">http://www.lonniebest.com/FormatCSS/</a></li>
<li><a href="http://www.cssdrive.com/index.php/main/csscompressor/" target="_blank">http://www.cssdrive.com/index.php/main/csscompressor/</a></li>
<li><a href="http://tools.arantius.com/css-compressor" target="_blank">http://tools.arantius.com/css-compressor</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/tbcompressor-intro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

