lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

After fixing a final few bugs in the new features I decided it was
about time to make a new release. Thanks to everyone who sent in bug
reports and helped test - especially Vadim Peretokin who helped me get
the gzip output compatible with Windows among other things.

Squish is a utility that takes a script and all the Lua modules it
uses, and builds them into a single standalone .lua file. While doing
this it can also run the output file through a number of filters to
reduce the size as much as possible.

Also supported is bundling "resources", which can be any file to be
packed into the output script and accessible at runtime. An optional
extension "virtual IO" allows you to make the resources appear as
standard files, so that (e.g.)"my/resource.png") accesses the
packed resource rather than searching the filesystem.

New in 0.2.0 is support for a gzip filter. This requires the
command-line 'gzip' program to produce the compressed script, however
the resulting script will decompress itself when run with no external
dependencies. This is thanks to the excellent compress.deflatelua
module by David Manura which (in a somewhat hacked, reduced and itself
compressed form) is included in the output.

Also I have extended the "uglify" filter to replace long, repeating
identifiers and string literals in addition to keywords. The uglify
filter is a specialised fast form of compression that replaces Lua
keywords with single bytes in the 128-255 range, and restores them on

Curious as to how the new features pan out, I decided to run some
tests on real-life code. I chose to use Steve Donovan's Penlight 0.8
for the test, it being the largest and most diverse pure-Lua library I
know of. A graph of running it through squish with various options can
be found here:

In summary, with all knobs turned to 11, squish reduced 215.3K of code
to 27.6K. This comes at a cost of +200ms load time for the gzip code
decompressing the script. Without gzip the smallest is 52.4K, and a
mere 24ms load time. Obviously this is an extreme example to
demonstrate the figures - a typical project would squish only the
individual files in Penlight that it needs to reduce size and load

The squished pl.lua for demonstration is at and a squished squish
0.2.0 is at .