Packing CSS, JS and PHP external libraries

Dear all,

Currently in my application, I'm used to pack all external libraries and JS, CSS files. The tools I use strip all blank spaces and documentations unneeded.

So the files delivered to the client are nearly 50% lighter than the primary files, and I can still working (in debug mode) with documented and "human readable" files.

Among own packing tools, I used YUI Compressor (BSD) and Javascript Packer (LGPL).

I think that these automations could be added easily in a framework.

Yes, we already have a ticket for this feature.

Personally I don't like packed files, according to several tests it's slow at the client end, and compressed/gzipped gives almost the same file size.

It will be an option of CClientScript. So you can either turn on or off the compression/packing.

Thanks for your replies.

I didn't find the ticket, I ask apologies.

Maxximus, I never eared this ; thank you to draw my attention to this point.

I'll have to take care of the performance.

@qiang: Great! I was just thinking about this feature in Yii actually :) It would be a nice addition to CClientScript. Will it be one property for compression and one for packaging or one for both?

Everybody is free to use Packer, but:

Minify: loose all comments, redundant white spaces etc.

Packer-Compressed (base62): The Minified JS code is compressed and it generates a new JS code, this is indeed smaller most of the times, but this is just playing dumb because with a gzip transfer, the Minified file will quite similar than the Compressed one, and won't have to be processed, because JS compression instead of GZIP compression means:

Load JS > Decompress file (using JS!) > Load new JS > Use

The time obviously depends on each CPU power, but the thing is simple, you save some KB in exchange for loading time.

So Minify and GZIP will give you almost the same size of a Packed (with the special feature JS-Compressed) file, but is much faster in terms of user response. Packer can be used without it, and will just minify the file.

If you’re concerned about the last few bits, it’s probably worth to shrink your images a bit more ;).

JSMin is considered safe, fast and available in a PHP version. YUI compressor is Java only (depends on Rhino engine).

Thanks for the comment

There is also Dean Edwards JavaScript’s Packer  (LGPL 2.1) which is a PHP class.

Hmmm, this would be nice, depending on the debug status, the asset published could be minified or published unchanged drool

I'd also prefer jsmin, I've had problems with other compressors and gzip working together.