-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Compression is one of the most important things in a build system and I have the feeling that this is currently one of the weakest parts of our system. There are a couple of issues that I would like to see addressed before we move this project forward towards the glorified 1.0 release of the development branch.
YUI compressor
YUI has recently announced the deprication of their YUI compressor project. They are moving away from their Java based compressor and are embrascing opensource as the base of their compressor which they have named yUglify as it's based upon the excellent uglifyjs compressor. The new version add's some additional fixes upon the regular uglify compressor. Some of these fixes are already in our code base as well, such as appending an extra ; so it's easier to concatenate files after minification.
The CSS compressor has been replaced by CSSMin which is included in their yUglify package. The version bundled is a forked version and maintained version of CSSMin.
UglifyJS
UglifyJS has gained a new brother, UglifyJS2 this is the successor of the current uglify parser and it should be able to compress more then the current stable version.
JSMin
We should also support JSMin as some people seem to fancy that, it's also available with sourcemaps
CSS compression
The only CSS compressor that we are currently supporting is the one bundled in the YUIcompressor.jar, we should also different CSS compressors such as sqwish
Closure compiler
Closure compiler is awesome, but it's depends that Java is installed on your system. I would love to get rid of this dependency and only require node to be installed on the system. Google created a closure compiler service that runs on app-engine. We could leverage this service to compress the data if java is not installed.
The level option
We currently allow people to configure the compressor using a level option, this is just silly and doesn't provide any useful information about what it actually does and is overly complicated to understand for new comers. Instead we should just allow a comma separated list of compressors they want to use on their code base.
Compression detection
Less, important but nice to have.. Iterate over all the available compressors to figure out which compressor is the most effective for the given code base. As there are cases where closure compiler is more effective then uglifyjs. By checking out the best compilation we could advice users on compression levels. Also the order of compression is important, for example use closure first as it remove dead code and then uglify to save a couple more extra bytes.
Verification
We should verify if the compressed code is actually smaller when gzipped, if this is not the case, we should return the original source code.
Source maps
We need this.
TL;DR
- Remove yui compressor, and upgrade to yuglify
- Support more CSS compressors
- Detect if
javais available on the system, and use the closure.jar to minify. When it's not available we should use the close compiler service API to minify the data. - All the compressing should be delegated to a child process so the operations do not block our event loop. This crush cluster should take care of all minification related procedures and use the node cluster to distribute the workload to it's child processes.
- Add compression algorithm detection
- Don't use
levelbut add newengineorcompressoroption - Verify these results.
- Add source map support