<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>おいぬま日報 &#187; JavaScript</title>
	<atom:link href="http://tech.lampetty.net/tech/index.php/archives/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://tech.lampetty.net/tech</link>
	<description>Apache, MySQL, Perl, Python あたり</description>
	<lastBuildDate>Sun, 05 Feb 2012 12:36:09 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.lampetty.net/tech/index.php/archives/category/javascript/feed" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>YUI Compressorを使ってWordPressのjsファイルを圧縮する</title>
		<link>http://tech.lampetty.net/tech/index.php/archives/270?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yui-compressor%25e3%2582%2592%25e4%25bd%25bf%25e3%2581%25a3%25e3%2581%25a6wordpress%25e3%2581%25aejs%25e3%2583%2595%25e3%2582%25a1%25e3%2582%25a4%25e3%2583%25ab%25e3%2582%2592%25e5%259c%25a7%25e7%25b8%25ae%25e3%2581%2599%25e3%2582%258b</link>
		<comments>http://tech.lampetty.net/tech/index.php/archives/270#comments</comments>
		<pubDate>Thu, 12 Feb 2009 15:29:59 +0000</pubDate>
		<dc:creator>oinume</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[パフォーマンスチューニング]]></category>

		<guid isPermaLink="false">http://tech.lampetty.net/tech/?p=270</guid>
		<description><![CDATA[Webサイト高速化の手法の一つとして、Steve Souders さんが唱えている&#8221;Minify JavaScript and CSS&#8221; (JavaScriptとCSSを圧縮せよ) というのがあり [...]]]></description>
			<content:encoded><![CDATA[<p>Webサイト高速化の手法の一つとして、Steve Souders さんが唱えている&#8221;<a href="http://developer.yahoo.com/performance/rules.html#minify">Minify JavaScript and CSS</a>&#8221; (JavaScriptとCSSを圧縮せよ) というのがあります。若干今更感がありますが、ちょっとでも高速化するために、このブログで使用しているiNoveテーマのJSファイルを<a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a>を使って圧縮してみました。</p>
<h3>YUI Compressorのインストール</h3>
<p>例によってUbuntu 8.10な環境ですが、YUI CompressorはJava製なのでJDK 6.0を入れます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> sun-java6-jdk</pre></div></div>

<p>終わったらYUI Compressorをダウンロードして解凍します(以後、解凍してできたディレクトリを$YUI_ROOTとします)。</p>
<h3>WordPressのiNoveテーマで使っているJavaScriptファイルを圧縮</h3>
<p>試しにこのブログで使用しているテーマiNoveのJavaScriptをYUI Compressorを使って圧縮してみます。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>tech<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>themes<span style="color: #000000; font-weight: bold;">/</span>inove<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>
$ java <span style="color: #660033;">-jar</span> <span style="color: #007800;">$YUI_ROOT</span><span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>yuicompressor-2.4.2.jar menu.js <span style="color: #000000; font-weight: bold;">&gt;</span> menu.js.new</pre></div></div>

<p>結果は標準出力に書き出されるので、適当に別ファイルにでもリダイレクトします(-o でもOK)。出来上がったファイルのサイズを見てみると、下記のように5.8KBのファイルが4.0KBに減っているのがわかります。(約68%になりました)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> menu.js<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> kazuhiro kazuhiro 5.8K <span style="color: #000000;">2009</span>-02-<span style="color: #000000;">13</span> 00:<span style="color: #000000;">21</span> menu.js
<span style="color: #660033;">-rw-rw-r--</span> <span style="color: #000000;">1</span> kazuhiro kazuhiro 4.0K <span style="color: #000000;">2009</span>-02-<span style="color: #000000;">13</span> 00:<span style="color: #000000;">23</span> menu.js.new</pre></div></div>

<p>こうやってどんどんファイルを小さくしていけば、クライアントの.jsファイルの取得が速くなるのでサイトの高速化が見込めます。どのぐらい速くなるかはクライアントの海鮮速度に大きく依存するので一概には言えませんが、ガンガン圧縮して試してみると良いと思います。</p>
<div class="tmkm-amazon-view">
	<p><a href="http://www.amazon.co.jp/%E3%83%8F%E3%82%A4%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9Web%E3%82%B5%E3%82%A4%E3%83%88-%E2%80%95%E9%AB%98%E9%80%9F%E3%82%B5%E3%82%A4%E3%83%88%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B14%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%AB-Steve-Souders/dp/487311361X%3FSubscriptionId%3DAKIAJGVWECUONT35GEJA%26tag%3Dkazzhomeunixo-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D487311361X"><img src="http://ecx.images-amazon.com/images/I/51hIDIWHmYL._SL160_.jpg" border="0" alt="" /></a></p>
	<p><a href="http://www.amazon.co.jp/%E3%83%8F%E3%82%A4%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9Web%E3%82%B5%E3%82%A4%E3%83%88-%E2%80%95%E9%AB%98%E9%80%9F%E3%82%B5%E3%82%A4%E3%83%88%E3%82%92%E5%AE%9F%E7%8F%BE%E3%81%99%E3%82%8B14%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%AB-Steve-Souders/dp/487311361X%3FSubscriptionId%3DAKIAJGVWECUONT35GEJA%26tag%3Dkazzhomeunixo-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D487311361X">ハイパフォーマンスWebサイト ―高速サイトを実現する14のルール</a></p>
	<p><em>著者／訳者：</em>Steve Souders スティーブ サウダーズ </p>
	<p><em>出版社：</em>オライリージャパン( 2008-04-11 )</p>
	<p>大型本 ( 184 ページ )</p>
<hr class="tmkm-amazon-clear" /></div>
]]></content:encoded>
			<wfw:commentRss>http://tech.lampetty.net/tech/index.php/archives/270/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.lampetty.net/tech/index.php/archives/270" />
	</item>
	</channel>
</rss>

