Compressing Spry's JavaScript Files

While testing the latest copy of CF8 GMC, I looked at the file sizes of the Ajax javascript files and was pleasantly surprised to find the files nicely compressed…all except for the Spry files! I was curious as to why the CF8 team hadn't compressed them, especially when Sprydata.js is ~129k by itself.

So, I immediately went to Dean Edward's Packer, ran the Sprydata.js code through Packer, resaved the file and was proud of the 70k creation that I had just created. I then went and ran my CF8 test app and BOOM!! The app stopped working! So I replaced the new Sprydata.js with the backup and everything worked. Now, I've encountered this before with other libs. All is well until you pack em.

This really bugged me. I wanted to get the file sizes down. So I went to plan B; Dojo's Dojo's
ShrinkSafe
. Now, ShrinkSafe does a good job of compressing JS code but Packer is usually better but under the circumstances, if ShrinkSafe could get the job done, I'd be quite satisfied.

So I ran the Sprydata.js code through ShrinkSafe, re-saved the file and BAM! it worked!! Sprydata.js was now 72k and that's 57k less that has to be loaded when using the Spry controls in my CF8 code! I also updated SpryEffects.js and xpath.js, both used extensively with CF8's Ajax widgets. While the savings weren't as impressive as what I got with SpryData.js, it was still worth doing.

Unfortunately, Adobe won't be able to squeeze these updates into the final release of CF8 but at least you'll have the tools to do it on your own.