Welcome to the first entry in the ColdFusion Builder Contest. We didn’t get a lot of entries for this contest, but every entry is really darn cool, so I’m very excited to be able to share the first of the entries with you today. Our first entry is Squeezer and comes to us from Guust Nieuwenhuis.
As you can see, you have many options for how to process the files. To be honest, I'm not sure what some of these are, but I love the fact that you have the option to Save As. I mainly just took the defaults though and let it overwrite the file as is.
The results - again when it worked right and when I used it files that were not already minimized - were respectable. A good 50% cut on some files.
As to the code - first and foremost - he remembered the cardinal rule of CFBuilder extensions - disable debugging:
<cffunction name="onRequestStart" returnRequest="boolean" output="false">
<cfsetting showdebugoutput="false" enablecfoutputonly="false" />
I'm not quite sure what returnRequest is meant to be, but the important thing is he turned off debugging. Do not forget this.
Another interesting aspect is how he handles storing the data. One issue you run into with CFBuilder extensions is how to properly keep state over multiple requests. You can kinda use the Session scope at times but it is a bit wonky. He gets around this by simply using the Application scope. He stores his information in the Application scope under a numeric ID. He then passes that value over the URL from step to step so he can get it again later. This is a technique I kind of like and I may "innovate" into my own extensions.
Another nice feature - he makes use of JavaLoader, Mark Mandel's open source project that lets you make use of Java libraries without having to modify your class path or restart ColdFusion. Luckily this feature will get rolled into ColdFusion 10. (Because Adobe has said they will be integrating all of Mark's open source projects into ColdFusion. Yes, that's a joke. Kinda.)
All in all - a very handy little extension. You can grab it yourself via the download link below. (Edit: I've removed the download as it is now available at http://squeezer.riaforge.org/.) Thank you, Guust! (Quick reminder - don't forget that you should not extract the zip. CFBuilder will do it as part of the installation.)