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.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Big Gary's Gravatar *cough cough* ix-nay on the mc-gay
# Posted By Big Gary | 7/22/07 9:55 PM
Rey Bango's Gravatar @Gary: Adobe saw my post and their fine with it. In fact, their the ones that suggested I post about this issue so others can benefit from it. :)
# Posted By Rey Bango | 7/22/07 10:58 PM
Andy Matthews's Gravatar Can't fit it into the final release? It's just a few JS files!
# Posted By Andy Matthews | 7/23/07 1:02 AM
Rey Bango's Gravatar Yeah but they have to burn those onto CD. For the downloadable version, I guess they could update it.
# Posted By Rey Bango | 7/23/07 1:05 AM
Evert's Gravatar Do realize that 'js compression' is totally pointless if you gzip everything..

It's a poor mans compressing, if you have that kind of control over your setup already.. you might as well actually gzip it
# Posted By Evert | 7/23/07 1:27 AM
Gary Funk's Gravatar And Ben is pointing to this entry. And we all know that Ben is the Whole All Mighty of ColdFusion
# Posted By Gary Funk | 7/23/07 10:36 AM
Patrick Whittingham's Gravatar Thanks for the info. It would be nice if Adobe, 'auto-magically' remove those 'js functions' not being used by a given page, so it would reduce the size of the JavaScript files or even use less js files in Spry by combining them.
# Posted By Patrick Whittingham | 7/23/07 5:40 PM
Damon Cooper's Gravatar yes, Rey asked and received permission to blog this. He's single-handedly pushed us to squeeeeze our download sizes for AJAX stuff. Thanks Rey!

Damon and the CF team
# Posted By Damon Cooper | 7/23/07 8:08 PM
Rey Bango's Gravatar @Damon: Glad to have helped. CF8 is looking solid!
# Posted By Rey Bango | 7/23/07 11:54 PM
Ashwin's Gravatar What Damon said - thanks for pushing us to get the compression done!
# Posted By Ashwin | 7/24/07 4:28 AM
Peter TIlbrook's Gravatar Onya Rey for spotting this. I noticed you can do the same things with the Dreamweaver CS3 Spry generated .js files.

Unfortunately the CFMENU implementation is still way to slow compared to the DWCS3 alternative.
# Posted By Peter TIlbrook | 7/24/07 8:36 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.