<?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>Geospecialling &#187; YUI Compressor</title>
	<atom:link href="http://www.geospecialling.com/index.php/tag/yui-compressor/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geospecialling.com</link>
	<description>Being a (G)IS Developer...</description>
	<lastBuildDate>Thu, 26 Jan 2012 04:11:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Increase Mapguide Enterprise/Open Performance with Javascript Compression using the YUI Compressor</title>
		<link>http://www.geospecialling.com/index.php/2008/08/increase-mapguide-enterpriseopen-performance-with-javascript-compression-using-the-yui-compressor/</link>
		<comments>http://www.geospecialling.com/index.php/2008/08/increase-mapguide-enterpriseopen-performance-with-javascript-compression-using-the-yui-compressor/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 13:18:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Mapguide]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[YUI Compressor]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2008/08/increase-mapguide-enterpriseopen-performance-with-javascript-compression-using-the-yui-compressor/</guid>
		<description><![CDATA[Javascript compression is something I had on my list for the next major release of RADE.&#160; RADE is not quite ready for this step yet, so I thought I would give it a shot on Mapguide Enterprise and see what kind of results it would yield.&#160; For a small site or an internal site this [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript compression is something I had on my list for the next major release of RADE.&#160; RADE is not quite ready for this step yet, so I thought I would give it a shot on Mapguide Enterprise and see what kind of results it would yield.&#160; For a small site or an internal site this will probably not yield significant benefits.&#160; However if you run a large public site javascript compression could squeeze out some more performance as well as save you on bandwidth costs.&#160; Yahoo has a good article on <a title="empty cache performance" href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/" target="_blank" rel="tag">performance and the &quot;empty cache&quot;</a>.</p>
<p>I did some brief looking around and word on the internets is that the <a title="YUI Javascript compressor" href="http://developer.yahoo.com/yui/compressor/" target="_blank" rel="tag">YUI compressor</a> is one of the better compressors out there.&#160; The YUI compressor is an open source java applet.&#160;&#160; This *should* work with Mapguide Open, heck this might even be done already in MGOS &#8211; but I am only using Enterprise so I cannot confirm, deny, or test this.&#160;&#160; </p>
<p>Some of the key things the compressor will do:</p>
<ol>
<li>remove all comments </li>
<li>remove all white space and line breaks </li>
<li>rename all local variables and parameters to single characters </li>
</ol>
<p>The YUI compressor should not alter variable values or your logic in any way.</p>
<p>To use the YUI compressor you will need to <a title="Download Java" href="http://www.java.com/en/" target="_blank" rel="tag">have Java installed</a>.&#160; Note that if you have the Oracle client installed, you probably have Java already&#160; Once you have Java, you can download a copy of the <a title="download the YUI compress" href="http://www.julienlecomte.net/yuicompressor/" target="_blank" rel="tag">YUI compressor</a> (I&#8217;m going to start referring to it as the YC now&#8230;).&#160; If you don&#8217;t feel like downloading Java and the YC &#8211; I&#8217;ve attached the processed files at the bottom of this post.</p>
<p>Lets first look at the javascript shipped with Mapguide Enterprise.&#160; If you browse to your web server extension viewer files (the default location is C:\Program Files\Autodesk\MapGuideEnterprise2009\WebServerExtensions\www\viewerfiles I believe) you will see ten javascript files.&#160; If you choose to process these files on your own please back them up first.&#160; Don&#8217;t blame me if you don&#8217;t backup your files and something goes wrong =).</p>
<p>Before YC:</p>
<p><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image9.png" target="_blank"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="242" alt="Mapgude Enterprise Javascript before YUI Compression" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb9.png" width="499" border="0" /></a></p>
<p>Using the YC is simple:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\browserdetect.js browserdetect.js</pre>
</p></div>
</div>
<p>&#160;</p>
<p>Update the paths to Java and the YC as per your environment.&#160; Using the handy dir /B *.js &gt; go.bat I created a batch file of all the javascript files in the viewerfiles folder.&#160; Be sure to run this from a dos window in the viewerfiles folder, or update the paths.&#160; You will also need to create the comp folder in viewerfiles.&#160;&#160; Quick cut and pasting created the following batch file:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\browserdetect.js browserdetect.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\contextmenu.js contextmenu.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\digitize.js digitize.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\hashtable.js hashtable.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\initdwfctrl.js initdwfctrl.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\legend.js legend.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\numfmt.js numfmt.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\pngfix_map.js pngfix_map.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\sarissa.js sarissa.js</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> c:\oracle\product\10.2.0\client_1\jdk\bin\java.exe -jar f:\utils\YUICompress\yuicompressor-2.3.6\build\yuicompressor-2.3.6.jar -o comp\wz_jsgraphics.js wz_jsgraphics.js</pre>
</p></div>
</div>
<p>&#160;</p>
<p>(*Sorry about the overlap.&#160; I&#8217;m working on a new layout and am addressing that in there)</p>
<p>Running that output all of the compressed of the files down somewhat, to pretty significantly. </p>
<p align="left"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image10.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="223" alt="Mapgude Enterprise Javascript After YUI Compression" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb10.png" width="569" border="0" /></a></p>
<p>A quick comparison of one of the function calls:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">function</span> MenuData(menuName, arrowHeight, scrollInc, scrollDelay, minSize, iconScrollUp, iconScrollUpDisabled, iconScrollDown, iconScrollDownDisabled, owner, withIFrame, bkColor)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">function</span> MenuData(F,H,I,K,E,G,D,J,A,C,B,L)</pre>
</p></div>
</div>
<p>&#160;</p>
<p>As you can see &#8211; the savings can be significant.</p>
<p>I&#8217;m not using the <a title="fusion viewer" href="http://www.jasonbirch.com/nodes/2007/12/19/155/mapguide-open-source-more-fusion-less-confusion/" target="_blank" rel="tag">Fusion viewer</a> yet so I did not process those files, but I did check some of the JS in there and each script file had a huge header comment.&#160; It looks like Fusion could also benefit from some compression action.&#160; Please note, I&#8217;ve been running my web tier using this script for a day or two.&#160; I&#8217;ve not run any serious testing on this code &#8211; so try this at your own risk.&#160; You did make that backup I suggested, right?&#160; That said, I have not personally experienced any problems yet.&#160; Also, should you compress your viewerfiles and have problems be sure to try your backups.&#160; Especially before calling your dealer or Autodesk for help. (sorry product support and ADN guys.&#160; Please don&#8217;t hate me =] ).</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:e709df33-b7eb-4787-9e2d-dd73ac7bc3b0" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p> <a href="http://www.geospecialling.com/wp-content/uploads/2010/02/compressedJS.zip" target="_blank">Download some pre-compressed javascript files</a></p>
</div>
<p>if you would rather not run the YC yourself. </p>
<p>Enjoy!</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8cf6b803-e6e9-4c76-b59c-22402f72bde2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/Javascript" rel="tag">Javascript</a>,<a href="http://technorati.com/tags/Mapguide+Enterprise" rel="tag">Mapguide Enterprise</a>,<a href="http://technorati.com/tags/Mapguide+Open+Source" rel="tag">Mapguide Open Source</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2008/08/increase-mapguide-enterpriseopen-performance-with-javascript-compression-using-the-yui-compressor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

