Compress context menu item for Windows XP
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:
To take this one step further, you can add a “Compress” context menu item. To do so, follow these steps:
- Open an Explorer window.
- Under the Tools menu, click Folder Options.
- Click on the File Types tab.
- In the list, select “JS” and click the Advanced button.
- Click the New… button.
- In the Action field, type “Compress”.
- In the Application used to perform field, type “c:compress.bat “%1″”.
- Click OK.
- Click OK again.
- Click Close.
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.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.