<?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>American Butifarra &#187; CSS</title> <atom:link href="http://claude.betancourt.us/tag/css/feed/" rel="self" type="application/rss+xml" /><link>http://claude.betancourt.us</link> <description>Claude Betancourt&#039;s Personal Blog</description> <lastBuildDate>Fri, 16 Dec 2011 02:43:25 +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>Compress JavaScript and CSS as Part of your Build Process</title><link>http://claude.betancourt.us/compress-javascript-and-css-as-part-of-your-build-process/</link> <comments>http://claude.betancourt.us/compress-javascript-and-css-as-part-of-your-build-process/#comments</comments> <pubDate>Mon, 05 Jul 2010 04:56:20 +0000</pubDate> <dc:creator>Claude</dc:creator> <category><![CDATA[How-To]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Compression]]></category> <category><![CDATA[Concatenation]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Performance]]></category> <category><![CDATA[Web Developement]]></category><guid isPermaLink="false">http://claude.betancourt.us/?p=736</guid> <description><![CDATA[Web page performance is critical to keeping customers and visitors moving along on your site. Slow responses typically result in frustrated users, unhappy customers and worse, abandoned orders. It is important to reduce the number of requests generated by a web page in order to increase its actual and perceived performance. <a href="http://claude.betancourt.us/compress-javascript-and-css-as-part-of-your-build-process/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Web page performance is critical to keeping customers and visitors moving along on your site. Slow responses typically result in frustrated users, unhappy customers and worse, abandoned orders. It is important to reduce the number of requests generated by a web page in order to increase its actual and perceived performance.</p><p>One critical way is to reduce the number of external files loaded by a page. Another one is to reduce their size through compression. This post aims to take this concept a step further by automating this tedious process using open-source libraries.</p><p><span id="more-736"></span></p><h3>Example</h3><p>This example will accomplish the task by executing the following steps:</p><ol><li>Create a temporary directory, <code>/build</code></li><li>Compress each JS file into <code>{original}-min.js</code> files</li><li>Compress each CSS file into <code>{original}-min.css</code> files</li><li>Concatenate all compressed JS files into <code>/js/complete.js</code></li><li>Concatenate all compressed CSS files into <code>/css/complete.css</code></li></ol><h3>Requirements</h3><ul><li>Make sure <a href="http://ant.apache.org/" alt="Apache Ant" title="Apache Ant">Apache Ant</a> has been installed on your system.</li><li>Check out a copy of the <a href="http://svn.betancourt.us/public/yui-compression-sample/">sample project</a> from my public SVN repository. This project already contains the open-source libraries necessary, <a href="http://yhoo.it/3FXTgK">YUI compressor</a> and <a href="http://bit.ly/avcPrG">YUI compressor Ant task</a>.</li><li>Setup a system variable, <code>COMPRESSOR_HOME</code> that points to the location of the sample project&#8217;s <code>/lib</code> directory.<ul><li>On Windows, right click My Computer and select properties. Then click the &#8220;Environment Variables&#8221; button under the advanced tab. Add a new system variable, <code>COMPRESSOR_HOME</code>, and set its value to your local path, for example: <code>C:\Documents and Settings\username\Desktop\yui-compression-sample\lib</code></li><li>On Mac OSX and Linux, update <code>~/.profile</code> or similar file and add <code>export COMPRESSOR_HOME=~/YourProjectDir/yui-compression-sample/lib</code></li></ul></li></ul><h3>Examine the configuration</h3><p>Take a look at the contents of <code>build.xml</code>. The first portion defines variables and locations of the libraries.</p><pre class="brush: xml; title: ; notranslate">
&lt;!-- tells Ant to refer to your environment vars --&gt;
&lt;property environment=&quot;env&quot; /&gt;

&lt;!-- defines location of libraries --&gt;
&lt;property name=&quot;lib.dir&quot; value=&quot;${env.COMPRESSOR_HOME}&quot; /&gt;

&lt;!-- defines output directory --&gt;
&lt;property name=&quot;build.dir&quot; value=&quot;build&quot; /&gt;

&lt;!-- output files, one for JS one for CSS --&gt;
&lt;property name=&quot;final_js&quot; value=&quot;${basedir}/js/complete.js&quot; /&gt;
&lt;property name=&quot;final_css&quot; value=&quot;${basedir}/css/complete.css&quot; /&gt;

&lt;!-- define nicknames for libraries --&gt;
&lt;property name=&quot;yui-compressor&quot; location=&quot;${lib.dir}/yuicompressor-2.4.2.jar&quot; /&gt;
&lt;property name=&quot;yui-compressor-ant-task&quot; location=&quot;${lib.dir}/yui-compressor-ant-task-0.5.jar&quot; /&gt;

&lt;!-- adds libraries to the classpath --&gt;
&lt;path id=&quot;yui.classpath&quot;&gt;
	&lt;pathelement location=&quot;${yui-compressor}&quot; /&gt;
	&lt;pathelement location=&quot;${yui-compressor-ant-task}&quot; /&gt;
&lt;/path&gt;

&lt;!-- define tasks --&gt;
&lt;taskdef name=&quot;yui-compressor&quot; classname=&quot;net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask&quot;&gt;
	&lt;classpath refid=&quot;yui.classpath&quot; /&gt;
&lt;/taskdef&gt;
</pre><p>The second portion of <code>build.xml</code> defines the Ant targets to be executed. These tell YUI compressor how the source files are to be processed.</p><pre class="brush: xml; title: ; notranslate">
&lt;!-- targets --&gt;
&lt;target name=&quot;concat&quot;&gt;

	&lt;!-- concatenates all compressed JS files into one --&gt;
	&lt;concat destfile=&quot;${final_js}&quot; force=&quot;true&quot; fixlastline=&quot;true&quot;&gt;
		&lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;**/*.js&quot; /&gt;
		&lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;**/widgets/*.js&quot; /&gt;
	&lt;/concat&gt;

	&lt;!-- concatenates all compressed CSS files into one --&gt;
	&lt;concat destfile=&quot;${final_css}&quot; force=&quot;true&quot; fixlastline=&quot;true&quot;&gt;
		&lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;**/*.css&quot; /&gt;
		&lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;**/flexgrid/*.css&quot; /&gt;
	&lt;/concat&gt;

&lt;/target&gt;

&lt;target name=&quot;compress&quot;&gt;

	&lt;!-- compresses each JavaScript and CSS file --&gt;
	&lt;!-- and saved as {original_name}-min.{extension} --&gt;
	&lt;yui-compressor
		warn=&quot;false&quot;
		munge=&quot;true&quot;
		preserveallsemicolons=&quot;false&quot;
		fromdir=&quot;${basedir}&quot;
		todir=&quot;${build.dir}&quot;
	/&gt;

&lt;/target&gt;

&lt;!-- deletes the temporary directory and all its contents --&gt;
&lt;target name=&quot;clean&quot;&gt;
	&lt;delete dir=&quot;${build.dir}&quot;/&gt;
&lt;/target&gt;

&lt;!-- creates the temporary directory --&gt;
&lt;target name=&quot;start&quot;&gt;
	&lt;mkdir dir=&quot;${build.dir}&quot; /&gt;
&lt;/target&gt;

&lt;target name=&quot;main&quot; depends=&quot;start,compress,concat,clean&quot; /&gt;
</pre><h3>What does this do?</h3><p>If you are new to Ant you are probably wondering why the tasks are defined in reverse order of execution. This is just a personal preference and it does not affect execution.</p><p>The order of execution is controlled by the <code>main</code> task. This is the task Ant runs when a target is not passed to it. The attribute <code>depends</code> tells Ant the order in which the tasks must be executed.</p><h3>Give it a try</h3><p>All you have to do to execute the entire operation is open a command prompt (or a terminal window on OS X), change into the project directory where <code>build.xml</code> lives and type <code>ant</code> and hit <code>Enter</code>. You should see some output that looks like this:</p><pre class="brush: plain; highlight: [19,20,32]; light: true; title: ; notranslate">
claude$ ant
Buildfile: build.xml

start:
     [echo] Building JS-CSS-Compression-and-Concat-Sample with Apache Ant version 1.7.1 compiled on April 8 2010 - System Java 1.6
    [mkdir] Created dir: /Users/claude/Documents/www/yui-compression-sample/build

compress:
[yui-compressor] [53%] global-print.css [920] ---&gt; global-print-min.css [488]
[yui-compressor] [80%] global.css [11895] ---&gt; global-min.css [9564]
[yui-compressor] [79%] style.css [1148] ---&gt; style-min.css [910]
[yui-compressor] [64%] googlemaps-yelp-ext.js [6604] ---&gt; googlemaps-yelp-ext-min.js [4270]
[yui-compressor] [70%] split-filepath.js [814] ---&gt; split-filepath-min.js [576]
[yui-compressor] [73%] ContactForm.js [4711] ---&gt; ContactForm-min.js [3461]
[yui-compressor] [57%] InfoTabs.js [1160] ---&gt; InfoTabs-min.js [669]
[yui-compressor] [55%] InfoWindow.js [1228] ---&gt; InfoWindow-min.js [686]
[yui-compressor] [68%] Intraday.js [9559] ---&gt; Intraday-min.js [6536]
[yui-compressor] [68%] MediaCenter.js [5728] ---&gt; MediaCenter-min.js [3906]
[yui-compressor] [JavaScript] Compressed 7 files to 67% (29KB to 19KB, saving 10KB)
[yui-compressor] [CSS] Compressed 3 files to 78% (13KB to 10KB, saving 3KB)
[yui-compressor] Compressed 10 files to 70% (42KB to 30KB, saving 12KB)

concat:
     [echo] Building /Users/claude/Documents/www/yui-compression-sample/js/complete.js
     [echo] Building /Users/claude/Documents/www/yui-compression-sample/css/complete.css

clean:
   [delete] Deleting directory /Users/claude/Documents/www/yui-compression-sample/build

main:

BUILD SUCCESSFUL
Total time: 1 second
</pre><h3>What Now?</h3><p>Change your HTML code to point to the newly created <code>complete.js</code> and <code>complete.css</code> instead of the individual files. Your page will load and render faster.</p><p>Squeeze even more performance out of your site by implementing other best practices. Get a copy of <a href="http://amzn.to/cueRAt">High Performance Web Sites</a> by Steve Souders and read <a href="http://yhoo.it/bjbsh4">Yahoo&#8217;s rules for exceptional performance</a>.</p><p class="note">Watch <a href="http://www.youtube.com/watch?v=BTHvs3V8DBA#t=90s">Steve Souders&#8217; presentation at Google Tech Talks</a>. Audio problems are fixed 5 minutes in. Skip the first 90 seconds to listen to Steve.</p> ]]></content:encoded> <wfw:commentRss>http://claude.betancourt.us/compress-javascript-and-css-as-part-of-your-build-process/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating an Apple Style Menu with Animation</title><link>http://claude.betancourt.us/create-apple-style-top-navigation/</link> <comments>http://claude.betancourt.us/create-apple-style-top-navigation/#comments</comments> <pubDate>Mon, 28 Jul 2008 22:23:29 +0000</pubDate> <dc:creator>Claude</dc:creator> <category><![CDATA[How-To]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Apple]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Photoshop]]></category> <category><![CDATA[Sprites]]></category><guid isPermaLink="false">http://claude.betancourt.us/blog/?p=107</guid> <description><![CDATA[Kriesi Budschedl has posted a very detailed tutorial to help you build your own Apple.com style menu and adds a nice touch by animating it. <a href="http://claude.betancourt.us/create-apple-style-top-navigation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><span class="drop_cap">K</span>riesi Budschedl has <a href="http://www.kriesi.at/archives/apple-menu-improved-with-jquery"><b>posted a very detailed tutorial</b></a> to help you build your own Apple.com style menu and adds a nice touch by animating it.</p><p><img class="alignleft frame" src="/images/blog/assets/tutorial-kwicks-home.jpg?2ce803" border="0" /></p><p>To construct the basic menu, Kriesi takes advantage of <a href="http://www.alistapart.com/articles/sprites" title="CSS Sprites: Image Slicing's Kiss of Death">CSS Sprites</a>, a technique to reduce the number of image files necessary to accomplish things like rollovers, without the need to preload the images using JavaScript.</p><p>A single image contains all the navigation menu options in their normal and active states and CSS rules are used to move the appropriate menu option into view. Once the basic menu is working, animation is added by using <a href="http://www.jeremymartin.name/projects.php?project=kwicks">Kwicks for jQuery</a>, a plugin written by Jerry Martin, resulting in the <a href="http://www.kriesi.at/wp-content/extra_data/kwicks_tutorial/kwicks_final.html">final product seen here</a>.</p><p><a href="http://www.kriesi.at/wp-content/extra_data/kwicks_tutorial/kwicks_final.html" title="Final product"><img class="aligncenter" src="/images/blog/assets/tutorial-kwicks-working-menu.png?2ce803" border="0" /></a></p> ]]></content:encoded> <wfw:commentRss>http://claude.betancourt.us/create-apple-style-top-navigation/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Improving Performance by Combining Scripts and CSS</title><link>http://claude.betancourt.us/improving-performance-by-combining-scripts-and-css/</link> <comments>http://claude.betancourt.us/improving-performance-by-combining-scripts-and-css/#comments</comments> <pubDate>Wed, 09 Apr 2008 13:53:45 +0000</pubDate> <dc:creator>Claude</dc:creator> <category><![CDATA[How-To]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[JavaScript]]></category><guid isPermaLink="false">http://claude.betancourt.us/blog/?p=128</guid> <description><![CDATA[According to the Yahoo! performance team, the best way to improve your web site&#8217;s performance is to reduce the number of requests for assets such as scripts, style sheets and images. One way to accomplish this is by combining all &#8230; <a href="http://claude.betancourt.us/improving-performance-by-combining-scripts-and-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><span class="drop_cap">A</span>ccording to the <a title="Exceptional Performance" href="http://developer.yahoo.com/performance/"><strong>Yahoo! performance team</strong></a>, the best way to improve your web site&#8217;s performance is to <a title="YSlow Rule #1" href="http://developer.yahoo.com/performance/rules.html#num_http"><strong>reduce the number of requests</strong></a> for assets such as scripts, style sheets and images. One way to accomplish this is by combining all the script files into one and serving only that file in your production environment. The same approach can also be applied to cascading style sheets.</p><p>The guys at <a title="Cozi.com" href="http://www.cozi.com/"><strong>Cozi</strong></a> <a href="http://blogs.cozi.com/tech/2008/04/combining-js-an.html"><strong>have created a server side solution</strong></a> that takes the pain out of combining these files in some sort of intermediary build process. Here is how they go about doing it:</p><blockquote><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas; color: blue;">&lt;</span><span style="color: #a31515;"><span style="font-size: 10pt; font-family: Consolas;">WebClientCode</span></span><span style="font-size: 10pt; font-family: Consolas; color: blue;">:</span><span style="color: #a31515;"><span style="font-size: 10pt; font-family: Consolas;">CombinerControl</span></span><span style="font-size: 10pt; font-family: Consolas;"> <span style="color: red;">ID</span><span style="color: blue;">=&#8221;CombineScript&#8221;</span> <span style="color: red;">runat</span><span style="color: blue;">=&#8221;server&#8221;&gt;</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">script</span> <span style="color: red;">src</span><span style="color: blue;">=&#8221;script/third-party/jquery.js&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">script</span> <span style="color: red;">src</span><span style="color: blue;">=&#8221;script/third-party/sifr.js&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">script</span> <span style="color: red;">src</span><span style="color: blue;">=&#8221;script/third-party/soundmanager.js&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas;"><span style="color: blue;">&lt;</span><span style="color: #a31515;">script</span> <span style="color: red;">src</span><span style="color: blue;">=&#8221;script/cozi_date.js&#8221;</span> <span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; line-height: normal;"><span style="font-size: 10pt; font-family: Consolas; color: blue;">&lt;/</span><span style="color: #a31515;"><span style="font-size: 10pt; font-family: Consolas;">WebClientCode</span></span><span style="font-size: 10pt; font-family: Consolas; color: blue;">:</span><span style="color: #a31515;"><span style="font-size: 10pt; font-family: Consolas;">CombinerControl</span></span><span style="font-size: 10pt; font-family: Consolas; color: blue;">&gt;</span></p><p>The combiner outputs a reference to an Http Handler which will serve the combined file:</p><p class="MsoNormal" style="margin: 0cm 0cm 10pt;"><span style="font-size: 10pt; line-height: 115%; font-family: Consolas; color: blue;">&lt;</span><span style="color: #a31515;"><span style="font-size: 10pt; line-height: 115%; font-family: Consolas;">script</span></span><span style="font-size: 10pt; line-height: 115%; font-family: Consolas;"> <span style="color: red;">src=<span style="font-size: 10pt; font-family: Consolas; color: blue;">&#8220;../Combiner/Combiner.ashx?ext=js ?<br /> &amp;ver=59169b00 ?<br /> &amp;type=text%2fjavascript ?<br /> &amp;files=!script&#8217;third-party*jquery*sifr*soundmanager*!script*cozi_date*&#8221; ?<br /> </span></span><span style="color: red;">type</span><span style="color: blue;">=&#8221;text/javascript&#8221;&gt;&lt;/</span><span style="color: #a31515;">script</span><span style="color: blue;">&gt;</span></span></p></blockquote><p>Although they do not provide the source code for the ASP.NET control, they do point to an old article on Vitamin, <a href="http://www.thinkvitamin.com/features/webapps/serving-javascript-fast"><strong>Serving JavaScript Fast</strong></a>, that served as their inspiration.</p><p>Personally I prefer combining the files before they get pushed to production in a build process, as doing it while the client may introduce unexpected delays depending on the traffic load a any given time.</p><p>What do you do to improve performance on your web sites?</p> ]]></content:encoded> <wfw:commentRss>http://claude.betancourt.us/improving-performance-by-combining-scripts-and-css/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: claude.betancourt.us @ 2012-02-07 14:05:50 by W3 Total Cache -->
