Wednesday, March 7th, 2007

JSJuicer: Slice and Dice those JS files

Category: JavaScript, Utility

jsjuicer is a free tool for safely reducing the size of your JavaScript files. Reducing the size and number of the JavaScript files included in a web page will enable it to load faster. It is available as portable C++ code with a BSD-style licence.

Why did Adrian Johnston write another JavaScript obfuscater and minimizer?

For a number or reasons. I wanted something portable I could run on both windows and Linux from the command line. I also wanted something that came with source code that I could understand and maintain, in order to be able to debug any problems I might have with the somewhat scary minimization and obfuscation process. Finally, I was worried by the dire “if you forget a semicolon or use an API symbol that isn’t on our list you are toast” warnings associated with many tools. In the end it was easiest to just extend JSMin to meet these requirements. As the result is substantially different than JSMin, I’m distributing it as a new program.

Download JSJuicer 1.0

Posted by Dion Almaer at 6:06 am
11 Comments

+++--
3.9 rating from 20 votes

11 Comments »

Comments feed TrackBack URI

“;;;” as a prefix for debug code? Where have I seen that idea before?

Gonna check this out though…

Comment by Dean Edwards — March 7, 2007

This looks neat, but I personally prefer the Dojo compressor – it’s based on the Mozilla Rhino Javascript interpreter, so it is pretty safe, and it creates well-compressed code. It’s portable, as well, although it is written in Java. Their page is at http://dojotoolkit.org/docs/compressor_system.html .

Comment by Andy S — March 7, 2007

Come on this is really not a news. the dojo compressor is many times better, we don’t need this piece of software.

Comment by alex — March 7, 2007

“Come on this is really not a news. the dojo compressor is many times better, we don’t need this piece of software.”

Thats silly. There’s new AJAX libs coming out all the time, are you gonna tell ajaxian to stop telling us about them too? There may be a better compressor, but what adrian did is a good thing. He took the time to learn something for himself and empowered himself with a more control over his work. Plus, maybe something he did will inspire someone else or raise the bar for further compressors. I’m sick of commentors like you complaining every time a new version of an old trick is announced. Competition brings innovation and change. Its a good thing.

Comment by Tim — March 7, 2007

The Dojo compressor turns ‘test = “ö”;’ into ‘test=”\u221a\u2202″;’ in UTF8 encoded files, which is clearly wrong.

Comment by Martin Bialasinski — March 7, 2007

If someone wants to test this new tool, I’ve quickly done a web edition.
You can try it at http://labs.gueschla.com/jsjuicer/

Comment by Boris Popoff — March 7, 2007

If you really want to compress javascript, there is no better tool than MemTronic’s Freeware HTML/JavaScript cruncher.. http://hometown.aol.de/_ht_a/memtronic/

it even crunches HTML and CSS in addition to JavaScript.

Comment by Damien — March 7, 2007

I’ve just test it on a site with about 20 js files and it’s working very well (with prototype, script aculo, window prototype etc …).
I prefer such a C++ prog than a java prog cause I don’t need to install java… I’ve batched it in my svn deployment script and it’s very cool :)
Thank u !

Comment by Kochka — March 9, 2007

I’ve done some test.

– choice of original file as first argument after comment is not so safe (put for example this char “>” after a comment, bye bye source)

– multi line comments are not supported (I think a replace of “\n” or “\r” char for a multiline comment should be a good feature)

– there’s a new line both with or without comment (I know, it’s not a big problem)

– conditional “in code” JavaScript comments are not supported so different libraries should not work correctly after juice parsing

However, it seems to be a good simple and fast application, well done :)

Comment by Andrea Giammarchi — March 9, 2007

Hi Andrea. If you want to insert complex and multi-line comments, you can quote the comment with a single quote (‘) character in the bash shell. This allows you to use any character except the single quote itself. If you are using another shell or even calling the command from code there should always be a way to have the comment passed as the first argument to the program. As for conditional comments, I’ll add support for them.

Comment by Adrian — March 9, 2007

Version 1.1 is out and it supports IE’s conditional comments.

Comment by Adrian — March 13, 2007

Leave a comment

You must be logged in to post a comment.