Shrinker/packer/obfuscator?

They have: 173 posts

Joined: Feb 2005

What tool do you use to obfuscate/shrink your javascript source code?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I don't. Trying to hide client-side Javascript code is like trying to hide XHTML: futile. Since your program must be transferred in whole, to be read in text form by the client, there is no way you can hide it from the user.

As with markup code, you may save a kilobyte or two by compacting whitespace, but the payoff isn't really worth the effort.

Smiling

They have: 173 posts

Joined: Feb 2005

Abhishek Reddy;210033 wrote: I don't. Trying to hide client-side Javascript code is like trying to hide XHTML: futile. Since your program must be transferred in whole, to be read in text form by the client, there is no way you can hide it from the user.

As with markup code, you may save a kilobyte or two by compacting whitespace, but the payoff isn't really worth the effort.

Smiling

I compacted the prototype from 60 to 40KB. That's 20kb every non-cached request. You can't possible sit there and tell me that's pointless savings.

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Triexa.com;210035 wrote: I compacted the prototype from 60 to 40KB. That's 20kb every non-cached request. You can't possible sit there and tell me that's pointless savings.

20kB isn't much of a savings, imo, not when you're satisfied with 40kB scripts. Why do you have 20kB of whitespace anyway? And a 40-60kB script?

I'd use a regular expression replacement to delete whitespace, if there was that much. No need for any extra tools.

Smiling

They have: 173 posts

Joined: Feb 2005

umm its protoype, WELL known javascript framework. It happens to be that size of a file.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Triexa.com;210042 wrote: umm its protoype, WELL known javascript framework. It happens to be that size of a file.

Oh right. Might be an idea to capitalise proper nouns to avoid confusion in future. Smiling

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

I have seen programs before that shrink source code by not only eliminating whitespace, but also by replacing all variable names with 2 letter ones. Yes the final code is confusing to read, but that is why you keep the original. Some sites, every singe byte saved can count.

-Greg

They have: 173 posts

Joined: Feb 2005

Greg K;210062 wrote: I have seen programs before that shrink source code by not only eliminating whitespace, but also by replacing all variable names with 2 letter ones. Yes the final code is confusing to read, but that is why you keep the original. Some sites, every singe byte saved can count.

-Greg

Are you able to point to any that do this?

SonicMailer Pro - Professional mailing list manager & award-winning email marketing software
Download a FREE 30-day trial today!
Use coupon savemoreon4 and save 10%!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.