<?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>Web Development&#187; htaccess</title>
	<atom:link href="http://webdevelopment.kerryjones.net/c/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdevelopment.kerryjones.net</link>
	<description>Web Development Tips &#38; Tricks, the things that you don't want to figure out.</description>
	<lastBuildDate>Wed, 05 Aug 2009 17:03:03 +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>Shrinking Javascript the Better Way</title>
		<link>http://webdevelopment.kerryjones.net/htaccess/shrinking-javascript-the-better-way/</link>
		<comments>http://webdevelopment.kerryjones.net/htaccess/shrinking-javascript-the-better-way/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 21:56:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[JSMin]]></category>
		<category><![CDATA[minimize]]></category>
		<category><![CDATA[shrink]]></category>

		<guid isPermaLink="false">http://phoenixdev.wordpress.com/?p=44</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Hello everyone!</p>
<p>There are many ways to shrink or obfuscate Javascript, simply search Google and you should find plenty of results. I found that many are programs that shrink it, then you upload the new code, which I was going to use until I found a better solution.</p>
<p>I found two that were recommended, jspacker and JSMin. After searching for jspacker and finding their site down, I went to <a title="JSMin Home" href="http://javascript.crockford.com/jsmin.html" target="_blank">JSMin</a>. I found links at the bottom for PHP code that would do it on the spot, which made me happy because I figured I could figure out a way to do something tricky with it, which I did.</p>
<p>Through the use of .htaccess, JSMin and another file I created, I made the site I was working on automatically shrink all my Javascript files when called, but look completely normal in Dreamweaver.</p>
<p>Here&#8217;s the code:</p>
<fieldset>
<legend>.htaccess</legend>
<p>Options +FollowSymLinks<br />
RewriteEngine on</p>
<p>RewriteRule &#94;<span style="color: #01b800;">js</span>/(.*).js$ /<span style="color: #01b800;">js</span>/minimize.php?jsPage=$1 [L]</p>
</fieldset>
<p>Quick note, I keep all my Javascript files in a folder called &#8220;js&#8221; which is also where &#8220;minimize.php&#8221; is located. You can adjust this according to your setup.</p>
<fieldset>
<legend>includes/minimize.php</legend>
<p>&lt;?php<br />
require(&#8216;<span style="color: #01b800;">../includes/jsmin.php</span>&#8216;);</p>
<p>// Output a minified version of the Javascript file.<br />
echo JSMin::minify(file_get_contents($_GET['jsPage'] . &#8216;.js&#8217;));<br />
?&gt;</p>
</fieldset>
<p>Again, should adjust the include of the &#8220;jsmin.php&#8221; which can be <a href="http://code.google.com/p/jsmin-php/" target="_blank">downloaded here</a>. Also, with the way I set it up, &#8220;minimize.php&#8221; must be in the same folder. You can adjust all of this however you like, but this was the best for my use.That&#8217;s it! Basically what&#8217;s happening is when the site calls your &#8220;example.js&#8221; file, it instead reads the file &#8220;minimize.php?JSPage=example&#8221;, which then minimizes and outputs the &#8220;example.js&#8221;.</p>
<p>-Kerry</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevelopment.kerryjones.net/htaccess/shrinking-javascript-the-better-way/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

