Hi All,
I'm trying to enter a javascript competition where the script has to be <= 1kb in size. Minifying and eval is allowed, so I've run it through google's closure compiler (which does slightly better than any others I've tried).
But I've found that if I convert the script to a string, and replace long words like 'function' and 'return' with single chars, I can reduce that even further. Then, by embedding the string in my script, performing the substitution to restore it, and then 'evaling' it, I can get the original behaviour.
So I was wondering if I could generalise this last method. Has anyone seen or written code to compress/decompress strings in this way? Feel like thinking about it?
EDIT To make myslelf clear, I'm asking about compressing and decompressing strings in javascript - not minifying. E.g. how to find the most common patterns in a string, and how to write a tiny decompressor in javascript for strings where these occurences have been replaced with single chars.
Thanks.