Just thought I'd share a quick tip. I'm one of the few developers I know who uses Windows almost exclusively (sorry, no Mac here). Lately, I've been wanting to see how my JavaScript files would be compressed using Julien's YUI Compressor. Previously, I was keeping a command window open and typing the command in directly. I figured there must be a simpler way to do this, and I was right.
The first step is download the YUI Compressor and put it somewhere handy. I put it directly in the c:\ directory for easy access. Then, I created a simple batch file called compress.bat and also placed it in c:\ for each access. The content of the batch file are as follows:
java -jar c:\yuicompressor-2.1.2.jar %1
This line essentially runs the YUI Compressor against a file that is specified as the first command-line argument (%1). You can now simply type the following into a command window:
c:\>compress.bat myfile.js
To take this one step further, you can add a "Compress" context menu item. To do so, follow these steps:
Once that is done, you can right-click on any file ending with a .js extension and see a context menu item called "Compress". When clicked, the command runs the YUI Compressor and the output is placed in the same directory.
I've found this to be a very handy way to use the YUI Compressor. I hope it's equally as useful for you.
I'm in the process of looking for a JS compressor right now, and ease of use is definitely high on the agenda. We're a Windows shop too, at least development time, so I'll definitely be adding YUI Compressor to my list of tools to check out!
Thanks
I kind of worked on a feature, years ago, for my site that would keep track of my JavaScript files, compress them on the fly if it detected a newer version, use the compressed versions on the site, and add the compressed (and updated original) to the downloadable zips. My only problem was my compressor sucked. I might do that for the website at work with the YUI compressor. After I port it to .NET, of course (yeah... I'm gonna do all that... ;) )
Post Comment
Your e-mail address will never be shown, only your URL. Please, no HTML in your comments, as it will be automatically stripped out for security purposes.