I couldn’t find anything that utilizes both and do compression without making API calls.
I didn’t do anything fancy I thought this util can help someone who want simple command line rather than remembering all the little things provided by individual compilers.
jcmin is in Beta. Not the actual compilers (Closure and YUI Compressor) but jcmin.
Important: jcmin is not a compiler itself.
You can say jcmin is a wrapper to YUI compressor and Google Closure and it only does basic stuff. I can add more Advance things if you like this util and want more control. As I said I developed this util for myself and I am kinda sharing it. If you end up finding it useful then consider donating or atleast a backlink to this page will much appreciated.
- .NET Framework >= 2.0
- Recommended: java.exe in System environment path.
Advantages of using this util
- Gives you option to choose between Google Closure and YUI Compressor
- You can minimize files under your directories
- You can even re curse through your directory and minimize files inside subdirectories. This util will form an equivalent structure at target directory.
- See Errors thrown by respective compiler.
- Comes with IKVM so if you dont have java installed compilers still work (I recommend to install it and put java.exe in Environment Path)
- You can skip any number of file by their name or even part of their name. so -excl=jque|ext will skip file names that contains jque and ext
- I am tired of typing this stuff, you will find out what Disadvantage you will come up with, so there is no point highlighting the advantages 🙂
- YUI compressor (when you select switch -use=yui Closure will not be used)
- Closure Stylesheets
Problems and Solutions
|If you have java.exe in Environment Path||If you don’t have java.exe. Build comes with IKVM.|
Recommended: Get Java Runtime Environment and put java.exe in Environment
Support me, well I know you won’t but its worth asking because I’ve got pending bills for bandwidth that I use :).
Lets see what this command line util is capable of.
shell> jcmin -source=PathToSourceJsFileDirectory -target=TargetDirectoryToStoreMinifiedFiles [options]
-v verbose mode ->default is off
-dnam do not add `.min` in target file names
-recursive Recursive search directory for .js and .css files
-use possible values yui|google, default is Google Closure
-excl exclude files, e.g. switch -excl=jquery|ext-all|jquery-ui... All the files that are mentioned will be excluded from minification.
-autf8 avoid UTF-8. Applies to YUI compressor. By default this value is true
-help print Usage help
TIP: when you specify -source or -target folders DO NOT put a trailing \ at the end. e.g. -source=""c:\demo\"" is wrong -source=""c:\demo"" is right.
TIP: When using recursion DO NOT put target folder as something inside your Source folder. so -source=""c:\demo"" -target=""c:\demo\output"" is wrong. There are obvious reason why this is bad. I'll leave it to you to find out why that is a bad Idea.
Things you should know
- Default encoding type for YUI compressor is UTF-8. Use –autf8 to avoid it.
- When you minimize CSS with Google Closure following options are used by default
- –allow-unrecognized-functions (this is to avoid errors when CSS functions such as scale are used )
- –allow-unrecognized-properties (this is to avoied error when non standard CSS rules are used)
Reason: Well I included those function and properties for a reason in my CSS file with side effects known so why do I need to see my CSS not getting minimized because of that.
Future versions (If you guys support this Util): Will give you control on passing such flags to the individual compilers.
Each compiler comes with some advanced options. I am keeping this version as simple as I possibly can. If you think an option can be added to this command either contact me directly through contact form or leave you comment.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
So bottom line is that I am not responsible for any damage you may cause to your files. It is always a good idea to backup your files to be on safe side.
I rushed through this post, so if you see any spelling mistakes please let me know