Tip Details Add a Related Tip

Rate as: Positive Negative

compressing javascript

There are a couple of reasons you may want to compress your Javascript code.

First is that by compressing your code there is less information to transfer to your users. This helps reduce the bandwidth and load on your server. And it make your pages feel faster to the end user.

Second, Javascript code can not be protected. Once it's out there, everyone can see the source. If you want to help slow people down from using your cool tricks, the obfuscation that results from compression can help. It's far from full-proof, but it may dissuade the casual person who's poking about.

If you want to compress your Javascript code, there's a new package out that will probably the standard soon. It's called ShrinkSafe and it's from the people who bring you Dojo. The big advantage of ShrinkSafe is that it's based on a Javascript interpretor (Rhino), not just a bunch of regular expressions. So it has the capability to make absolutely sure that the compression does not affect the functionality of your code.

The other nice thing about it is that it offers both a web interface, and a desktop application version, so you can use it as a service if you like or not. The web service is nice also in that it allows you to compress multiple files at one time.

You can check it out here: http://shrinksafe.dojotoolkit.org/
Rating: 100% positive, 1 Vote
Categories: javascript web Programming coding dojo
Added: on Jun 12, 2008 at 3:02 pm
Added By: an anonymous user

Comments on this Tip

Add a Comment
There are no comments for this tip
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Detecting if a variable exists in Javascript

100% positive, 1 comment - last added 2 days, 18 hours ago
– Tip added by an anonymous user on Jul 22, 2008 at 8:31 am

Static variables in Javascript

100% positive, 3 comments - last added on Aug 15, 2008 at 10:42 am
– Tip added by an anonymous user on Aug 03, 2007 at 4:19 pm

A better way to paginate through results

100% positive, 2 comments - last added on Mar 09, 2007 at 7:27 am
– Tip added by tipstr on Mar 08, 2007 at 12:33 pm

Scrolling HTML elements using the keyboard

100% positive, 1 comment - last added on Jul 18, 2008 at 3:53 pm
– Tip added by rlansky on Jun 22, 2007 at 9:34 am

Telling when an iframe is done loading

100% positive, 0 comments
– Tip added by an anonymous user on Apr 18, 2008 at 8:05 am

getting rounded corners without using background images

100% positive, 0 comments
– Tip added by tipstr on Mar 13, 2007 at 10:35 am

Optional parameters in javascript functions

100% positive, 0 comments
– Tip added by an anonymous user on Jul 30, 2008 at 10:44 am

Javascript variable naming

100% positive, 1 comment - last added on Jul 22, 2008 at 8:33 am
– Tip added by an anonymous user on Sep 30, 2007 at 7:28 am

Creating vector graphics in javascript

100% positive, 0 comments
– Tip added by Marcos84 on May 10, 2007 at 2:44 pm

attaching events to nodes in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 18, 2008 at 11:23 am

animating elements with jQuery

no ratings, 0 comments
– Tip added by an anonymous user on Aug 04, 2008 at 1:46 pm

Javascript: How to Create a Random Number

0% positive, 0 comments
– Tip added by Walkere on Feb 23, 2008 at 9:49 pm

Migrating from dojo 0.4 to 1.0

no ratings, 0 comments
– Tip added by an anonymous user on Jan 08, 2008 at 12:44 pm

Code for creating Javascript CSS charts

no ratings, 0 comments
– Tip added by an anonymous user on Aug 21, 2007 at 12:23 pm

Efficient building of large strings in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 08, 2007 at 12:52 pm

Avoid invalid title names when opening javascript windows

no ratings, 0 comments
– Tip added by an anonymous user on Aug 07, 2007 at 9:36 am

Nice article on javascript techniques

no ratings, 0 comments
– Tip added by rlansky on Apr 24, 2007 at 8:12 am

Viewing CSS and Javascript files

100% positive, 0 comments
– Tip added by an anonymous user on Aug 20, 2008 at 7:27 am

Matching any character in a javascript regular expression

100% positive, 0 comments
– Tip added by an anonymous user on Aug 18, 2008 at 9:06 am

Random number generation

100% positive, 0 comments
– Tip added by an anonymous user on Aug 05, 2008 at 6:49 am