470,810 Members | 1,207 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

JavaScript code minimizer (not obfuscator!)

Hi group,

A few years ago, I translated Douglas Crockford's JsMin from C to C#,
because we wanted to use this functionality in our build process. JsMin
is a code minimizer for JavaScript. It will remove all comments, empty
lines, turn tabs into single spaces, etc... The goal is to reduce the
size of JavaScript files to the minimum necessary, without modifying the
functionality.

Additionally to reducing the script's size, JsMin also makes it more
difficult to read, however it is not an obfuscator. Objects, variables,
methods names are not modified. While such a functionality wouldn't be
very difficult to add, we believe that it is pointless to obfuscate
JavaScript files.

Note: This is a direct translation from C (procedural) to C#. I didn't
refactor the object too much, so the design is far from perfect, but it
works well.

Note 2: I just found out that Douglas translated JsMin from C to C# too,
his version is available on his site, so pick the one you prefer ;-)

http://geekswithblogs.net/lbugnion/a...23/107120.aspx

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 23 '07 #1
2 3520
Laurent Bugnion [MVP] wrote:
JsMin is a code minimizer for JavaScript. It will remove all
comments, empty lines, turn tabs into single spaces, etc... The goal
is to reduce the size of JavaScript files to the minimum necessary,
without modifying the functionality.
Is there any benefit to JsMin over Packer?
I admit, I've not compared the two, but I use Packer.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Feb 23 '07 #2
Hi,

Matt Kruse wrote:
Laurent Bugnion [MVP] wrote:
>JsMin is a code minimizer for JavaScript. It will remove all
comments, empty lines, turn tabs into single spaces, etc... The goal
is to reduce the size of JavaScript files to the minimum necessary,
without modifying the functionality.

Is there any benefit to JsMin over Packer?
I admit, I've not compared the two, but I use Packer.
I don't know. Packer seems to obfuscate too, which we explicitly didn't
want in our project. Besides, I suspect that packer was not around when
we needed a code minimizer. I knew Douglas' JsMin already at that time,
so that's what we used.

I didn't compare either.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by Tom Cole | last post: by
4 posts views Thread by FAQ server | last post: by
reply views Thread by Laurent Bugnion [MVP] | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.