In a previous post, I explained how you can manually optimize JavaScript for size and/or create self-extracting compressed script using JsSfx. Today I release an updated version of JsSfx, which compresses script to even smaller sizes than the previous version and, as far as I know, smaller sizes than any other JavaScript compressor.
JsSfx is designed for use in the demo scene, where people often create JavaScript demos in a very limited number of bytes (and often a power of 2, such as 256 bytes, 512 bytes, 1Kb, 4Kb, etc…). In August/September of 2010, a demo competition was held at js1k.com. Contestants were asked to submit JavaScript demos that were 1024 bytes or less in size. A few of the entries used compression to fit a larger script into 1k. One of the more complex entries, WOLF1k by p01, uses cowboy‘s packify to compress 1370 bytes of script into exactly 1024 bytes. To see how well JsSfx was doing, I tested JsSfx1.2 on the 1370 uncompressed bytes of WOLF1k and found it reduced it to 1031 bytes. Obviously, I needed to improve on that, so I came up with an improved decoder for JsSfx3. The latest version compresses WOLF1k to 1013 bytes in utf-8 and 986 bytes using ISO 8859-1 (aka. latin-1). However, it does take a while to find the best way to compress scripts. JsSfx3 was developed with size in mind and not speed: it takes a minute or two to compress scripts of a few kilobytes. Compressing large scripts such as jQuery is not practical: it would probably take days on a fast computer.
There’s another competition over at js1k.com at the moment, but unfortunately compression is not allowed this time. Peter van der Zee, who hosts the contest, seems to believe that using compression removes the need for “hand tuning” your script and that this removes the fun. I disagree and believe WOLF1k and my own Perlin Noise script prove that. Also, I can assure you that a lot of “hand tuning” went into JsSfx3.2.
Anyway, if you’re working on small JavaScript demos and would like to see how small you can get your script, please give the new version a try and let me know if it works for you!


4 Comments to “JsSfx3.2 – JavaScript compression tool updated.”
2010/12/12
Actually after trying the packer I used for 3D Tomb II, I modified Cowboy’s packify to allow more tokens and optimized the uncompressor by 8 bytes.
Good job with Jssfx. Wish there was a JS version of it though.
2010/12/13
It should be easy enough to port if you can find somebody that has the time
. I automate building the compressed final version from human readable source, so I have no use for a JavaScript version myself.
2011/10/09
Hi, I add this line at the top of the file JsSfx.py to run on my linux:
#!/usr/bin/python
Excelente work with that, works really cool
2012/02/18
Hi. Thanks for JsSfx. I improved my own similar JavaScript crusher based on your work and submitted it to the current JS1k.