473,545 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3695
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2773
by: Tommo | last post by:
Hello All, I am a still learning so be easy on me. I am trying to get some code to work that is using JS and Perl/CGI, I am using AS Perl and an Apache Server on XP as the webserver. Can anyone take a look at the code and tell me why I am getting Apache Server errors in the code below (Part A), when I modify the code as shown in part B the...
53
5660
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
27
3310
by: Tom Cole | last post by:
I'm starting to do more quantity of javascript coding and thought this might be a good time to investigate code styling. I primarily develop in Java and currently use the code styling techniques spelled out for Java. For example, in my code blocks ( {} ) I always place the starting brace on the same line as the first line of code. For...
4
326
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I protect my javascript code? ----------------------------------------------------------------------- In the main, you can't as your code is distributed in source form and is easily readable. With JScript, there is the Script Encoder (see MSDN), but...
0
1399
by: Laurent Bugnion [MVP] | last post by:
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...
31
15316
by: ajos | last post by:
hi frnds, i have a form,which has 2 input text boxes, the values are entering the text boxes,when i leave the 2 text boxes blank and hit submit a java script gives the message that the 2 fields are blank.....the problem now is when i leave the text boxes blank the message appears...and when i click ok...then instead of showing me the page its...
1
1165
by: saritbhatta | last post by:
Hi, I am facing a problem regarding ajax and javascript. I want to get some html and javascript code as a responsetext from ajax. I am getting that in browser,but in Internet Explorer javascript code is not executing and giving error. What should i do? Please help me out from this problem.
47
65273
by: SOLAV | last post by:
This is the only working way to completely hide your JavaScript code from the client just like PHP or ASP code. Here we'll need the help of PHP. Here is the code: index.php ________________________________________________________ <?PHP @session_start(); //Start our session. if(@!session_is_registered('PrintTheJavaScript')){ //If the...
3
2423
nitindel
by: nitindel | last post by:
Hi, I have a text Box and want to apply javascript validation for not accpting Only Zero(s). For eg. If i enter 002308 ,it should accept but if enter 00000 or any number of Zeros alone ,it shold throw Error.. Please tell.It's Urgent. Thanks & Regards Nitin Sharma
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.