I am trying to introduce a javascript contest where the script should be <= 1kb in size. Minifying and eval are allowed, so I run it through the google close compiler (which is slightly better than any others I tried).
But I found that if I convert the script to a string and replace long words like "function" and "return" with individual characters, I can reduce this even further. Then, inserting the line into my script, doing the substitution to restore it, and then “evaling”, I can get the original behavior.
So I was wondering if I can generalize this last method. Has anyone seen or written code to compress / decompress strings this way? Feel how to think about it?
EDIT To make myslelf clear, I am asking about compression and decompression of lines in javascript - not minimization. For example. how to find the most common patterns in a string and how to write a tiny decompressor in javascript for strings where these occurrences have been replaced with single characters.
Thanks.
javascript string compression
sje397
source share