SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: encrypt my js!?

  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2005
    Posts
    456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    encrypt my js!?

    Hi All,
    I want to 'hide' my javascript from prying eyes. Whats the best compressor (or encryptor?) software? Im aware that some compressors just strip out white space, and that other compressors dont do a very good job and are easy to decompress. Others Ive tried just breaks my js. Im interested to hear what you guys have to say and what you use.
    many thanks

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you can really encrypt javascript. You can shrink variables and use base62 encoding to make javascript more difficult to read. Plus, filesize will be much smaller.

    Dean Edward's packer does a goed job at that:
    http://dean.edwards.name/packer/
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I set up my server to gzip it on the fly. That takes care of reducing it to about as small a size as it's going to get (yes, you can get it even smaller! but it's an insignificant improvement).

    I think its anti-social to compress/obfuscate Javascript, since a lot of what I've learned has been from looking at other people's scripts.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    It is not possible to hide javascript from prying eyes.

    It will always be possible to someone to figure out how to gain access to the javascript code.

    When it comes to packing, I usually find that it's best to, in an automated manner, join all the packed scripts together and append the timestamp of the most recent file to the name of the file, which helps with both filesize and caching issues.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •