#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    2
    Rep Power
    0

    javascript sourcecode compression


    for not reinventing the wheel ... is there an out-of-the-box library for
    compressing javascript sourcecode (probably utilising huffman encoding w/ a
    dictionary optimised for javascript sourcecode) and doing the decompression
    in javascript?

    the task is obvious: crunch sourcecode consisting mainly of function()
    declarations, store the resulting string in [wherever], download the whole
    enchilada through j(ava)script, decompress it, and use eval().

    can anyone point me to some useful resources? any help is appreciated.

    - niko
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    New York
    Posts
    122
    Rep Power
    14
    hombre:

    I'm not sure what your need is, but if you have need to compress your scripts, you can compress a .js file using any old jar utility (available with any java development kit) from the command prompt.

    You can then reference the compressed file in the same manner that you would reference any external .js file:

    <script src="your_compressed_file.jar"></script>

    You can manually unjar the file to edit it, but there's no need (or ability for that matter) to uncompress it in your scripts.

    Hope this was helpful.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    2
    Rep Power
    0

    need different technique


    szarecor:

    thanks for you hints.

    so far i understand that .jar files are a way to store, eventually compress javascript source files, probably sign them, and let the browser do the uncompression/installation (if that is an applicable term) of the resulting file.

    now, what i'd rather need is a technique which allows me to compress sourcecode and leave the compressed file in a way not too easily understandable by the average script ripper.

    you see, the point is: i'm currently developing quite a huge javascript application (> 40kb w/o comments, unnecessary whitespace stripped), divided into separate libraries, each one loaded on demand (not by a <script> tag but using a different technique). the library code will be dispersed among a bunch of additional resource files (images etc.) with an extension other than .js

    that means : compression + obfuscation ;o)

    as i'm putting quite a heavy effort into building the application, i'm also aware of the fact that a skilled js-programmer will be able to get a clue of what's going on and extract the full code, no matter what the 'protection' is.

    for that reason, i'm looking for some sort of compression which (a) provides c/c++ routines for doing the encoding in a win32 application, and (b) provides j(ava)script routines for decoding the stream.

    - niko
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    81
    Rep Power
    14
    I have a couple of JavaScript compression and obfusticating tools links on my tools page at:

    http://javascript.about.com/cs/tools/index.htm
    Robert Dominy
    About Guide for JavaScript
    http://javascript.about.com
    Software Consulting & Development
    http://www.angusog.com
  8. #5
  9. No Profile Picture
    Seņor Member
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2000
    Posts
    1,157
    Rep Power
    38

    Are you willing to wait?


    Michael
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    81
    Rep Power
    14
    Also, jar files are typically used for Java not JavaScript. Keep in mind these are two totally different languages. I can't imagine any scenarios where you would put JavaScript files into a .jar file.
    Robert Dominy
    About Guide for JavaScript
    http://javascript.about.com
    Software Consulting & Development
    http://www.angusog.com
  12. #7
  13. No Profile Picture
    Seņor Member
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2000
    Posts
    1,157
    Rep Power
    38

    What about signing scripts?


    Michael

IMN logo majestic logo threadwatch logo seochat tools logo