View Single Post
  #2 (permalink)  
Old June 29th, 2005, 08:16 AM
richard.york's Avatar
richard.york richard.york is offline
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Use a packer.
http://dean.edwards.name/packer/

It'll collapse the whitespace, and minimize the file size. As an added bonus it also obfuscates the code.

For example:

var file = '/my/sensitive/path';

Will still be there, albeit much more difficult to find or make sense of. In fact here is the output of that line using Dean Edward's packer:

Code:
eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[(function(e){return d[e]})];e=(function(){return'\\w+'});c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4 2=\'/0/1/3\';',5,5,'my|sensitive|file|path|var'.split('|'),0,{}))
There is a minimal amount of output that this will generate, so it works better for large, more complex scripts, as far as the packing goes.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote