-----------------------------------
Though it's a little off topic, for the benefit of the readership, here's a
brief discussion of the differences:
YUI Compression (and minification) essentially strips out all
whitespace/comments, shortens (safely) all internal variables, and removes
unnecessary code syntactics. The benefit is really good compression, but
extremely quick "initialization" (in other words, having it ready on your
page), because the code is directly executable in the page.
One other downside of YUI Compressor is that it strips out (or fails on,
sometimes) IE-conditional-compilation comments, which SWFObject uses. So,
SWFObject's authors actually remove the IE-conditional-compilation block,
YUI compress the code, then add the block back in, adjusting it to the right
minified variable names, etc. Kind of a pain, but this produces the best
result (see below).
Packing (like Dean Edwards' Packer, among others) uses a slightly different
concept -- it actually applies an advanced set of 'compression' packing
algorithm to the code, rearranging code blocks/commands, using techniques to
take advantage of looping, etc... and then it tacks onto the end a small
runtime that 'unpacks' the payload and passes it through an eval() statement
to evaluate it for execution on the page. Some 'packers' even actually use
real compression, like zip or gzip, with javascript implementations of the
decompressors. The benefit is much higher compression, but the tradeoff is
that the "decompression"/evaluation actually has some performance cost,
sometimes a few seconds worth, for it to initialize and be ready for the
page to use.
One additional factor is that a server can apply gzip/deflate compression on
the stream of text being sent to the browser, so a 'minified' script can be
'compressed' with gzip (usually on the fly) for transfer over-the-line, and
the browser takes care of natively uncompressing it. This type of
compression has much less performance cost. The main downside is that the
server (and browser, which most modern ones do) must support gzip
compression.
Generally speaking, for most scripts, YUI compression (minification)
combined with server/browser-gzip transfer turns out to be the best
combination -- it generally gets the best, most efficient "compression",
because it achieves close to (or better) compression to 'packers', but
without most of the runtime performance cost.
In fact, this URL will take any script and run it through several of the
most common minifiers/packers/compressors, and their various configuration
tuning options, and return a list of all combinations with size and runtime
speed costs. It sorts the list so you can see the best choice for your
script. http://compressorrater.thruhere.net/
Hope that helps. :)
--Kyle
--------------------------------------------------
From: "Micky Hulse" <rgm...@gmail.com>
Sent: Saturday, October 18, 2008 11:54 PM
To: "SWFObject" <swfo...@googlegroups.com>
Subject: Quick question: Packed or minified?
Disclaimer... this tool *IS* really picky, and as Doug says on his page, it
probably will "hurt your feelings" with what it complains about. I've never
had a script of mine COMPLETELY pass all its tests, but I often tweak my
scripts down to where there's only a few warnings that it gives, and in
doing so, I've never had a problem with my scripts failing to operate
identically after compression. It's just an extra step that takes some
effort and some learning to understand what JSLint outputs (some confusing
stuff you need to read his FAQ's about), but well worth it in my opinion.
One thing I love about this tool is that it actually interprets your
script's scoping usage, and lists all the different variables you use via
local, closure, global, etc. I often find variable misspellings this way,
because you can see all your variable names (at once, and per function) in a
simple list, and it even marks them if they've been used only once, or more
than once, to help you clue into problems.
Anyway, if you're writing a substantial amount of JS code in a library or
something, especially for others to use, it's very worthwhile.... if it's
just a few lines of custom code, it may be more of a hassle than necessary.
--Kyle
--------------------------------------------------
From: "Bobby" <bobbyvan...@gmail.com>
Sent: Monday, October 20, 2008 6:01 AM
To: "SWFObject" <swfo...@googlegroups.com>
Subject: Re: Quick question: Packed or minified?
>