In the last month or two we’ve had a number of tickets filed on the Rails Trac asking that Prototype adopt a more rigid syntax. Doing so would make it much easier to compress Prototype with tools like JSMin and Packer.
Opinions vary on this issue within the core team, but we all seem to agree that:
- We don’t want to distribute an official compressed version of Prototype.
- We don’t want to support a compressed version of Prototype. I’d rather eat glass than have to reconcile line numbers in a ticket someone filed against the compressed version.
- Some of the syntax requirements of compressors really harsh our mellow — for instance, Sam is not a fan of semicolons in one‐line functions, whereas I really don’t want to wrap one‐line
- Though there is a time and place for minification, we generally prefer other ways of reducing page weight:
mod_gzipand proper caching, for instance.
Thus: any tickets created on this subject will be summarily closed.
But we’re not naive — we know people will compress Prototype whether we endorse it or not. Steve Kallestad distributes compressed versions of Prototype and Scriptaculous, managing to reduce Prototype’s file size from 64K to 25K. That’s compelling.
Here’s a quick workflow to compress whatever version of Prototype you please:
- Grab the most recent stable version of Prototype, the bleeding‐edge version in source control, or whichever older version you prefer.
- Be safe: verify that your newly‐compressed version of Prototype passes all unit tests. (No whining! If you’re old enough to compress then you’re old enough to run unit tests, son.)