To make this process even smoother, as easy as drag-and-drop, we have provided a batch file (for Windows users) which can minify multiple files in a single go. To minify, you just need to drag-and-drop any JS or CSS files into the batch file and with the help of YUI compressor, the mininfied version of the file will be created in the same folder as that of the original file.
You can even right click on a JS or CSS file and use the “Open With” option and set it to execute with the provided batch file.
- Java needs to be installed on your system to execute YUI Compressor.
How it works:
- You can drag-and-drop multiple files over the batch file (you can even drag-and-drop .js and .css files together)
- The drag-and-dropped files are processed one-by-one
- YUI Compressor (which is stored in the same folder as that of the batch file) identifies the file type (.js or .css) and minifies it accordingly
- The new file is created in the original file’s folder and ‘.min’ is added before the extension of the original file name.
- There is no warning shown if the target “.min” file already exists. It will simply be overwritten.
:top @if [%1] ==  goto argsmissing :again @if [%1] ==  goto end @echo %1 @set opfile=%~n1.min%~x1 @%~d1 @cd "%~d1%~p1" @echo %opfile% @echo. @java -jar "%~d0%~p0yuicompressor-2.4.7.jar" --nomunge --disable-optimizations %1 -o "%opfile%" @REM - Shift the arguments (do not alter first argument) and examine %1 again @shift /1 @goto again :argsmissing @echo Argument(s) missing @echo usage: batFile.bat file1.js file2.css ... @echo. :end @pause
Latest posts by Priyank (see all)
- 525 million Google Plus accounts as of January 2013 - January 15, 2013
- Minify JS and CSS files in batch with drag-and-drop - January 6, 2013