[wp-hackers] Packing JavaScript

Alex Günsche ag.ml2007 at zirona.com
Tue Sep 18 19:31:51 GMT 2007

On Tue, 2007-09-18 at 13:48 -0500, Otto wrote:
> On 9/18/07, Charles <lists07 at wiltgen.net> wrote:
> > Another plus is speed benefits for end users.
> Compressed javascript is slower for end users, because you have the
> extra overhead of unpacking the javascript.

So, on the one hand, you propose to gzip everything, on the other hand
you dislike the overhead of unpacking the JS? Where's the logic in that?

> > JavaScript compression complements generic text compression nicely.  I use
> > "SetOutputFilter DEFLATE", and that works very well.
> I doubt that the minimal difference between packed JS and unpacked JS,
> given than both are being compressed using zlib, is highly
> significant.

Wrong again, sorry. Here are some figures:
For 2.3-beta3, the uncompressed overall amount of JS is 1,020,175 bytes,
the packed file size with that specific packer is 562,329 bytes (we know
these figures from before).

Now, let's delete the src files and compress the packed files:

for i in $(find ./wp-admin/ ./wp-includes/ -iname "*\.src\.js"); do rm $i; done
for i in $(find ./wp-admin/ ./wp-includes/ -iname "*\.js"); do gzip $i; done

(Note that I used the default gzip compression value, -9 would result in
even smaller files.)

And count again:
sum=0; for j in $(for i in $(find ./wp-admin/ ./wp-includes/ -iname "*\.js.gz"); do du -b $i | cut -f 1; done); do sum=$[ $sum+$j ]; done; echo $sum

The overall file size of the gzipped JS files is 256,051 bytes -- the
file size was again reduced by about 50%. This means, if you combine
gzipping and compressing, you might be able to reduce the overall
payload size to 25% of the original size.

> > Anyway, the combination of (1) JavaScript compression, (2) generic
> > server-side text compression and (3) file-combining is the norm, not the
> > exception, for sites that uses JavaScript for anything more serious than
> > roll-overs.
> 1 and 3 are useless in most (not all, mind you) cases. Whether it's
> the "norm" or not is debatable and largely opinion unless you can
> actually prove it with statistics. But whether they add a significant
> difference or not can actually be measured through testing. I submit
> that adding 1 and 3 to 2 will not produce a significant difference
> from just 2 alone.

Please provide arguments why a performance improvement is "useless". As
for statistics/testing, see my above examples.

Kind regards,

Alex Günsche, Zirona OpenSource-Consulting
Blogs: http://www.zirona.com/ | http://www.regularimpressions.net
PubKey for this address: http://www.zirona.com/misc/ag.ml2007.asc

More information about the wp-hackers mailing list