compressor Assets compressor for ClientScript


Assets minify and compressor for JS/CSS files using YUI compressor

Why another?

This supports files from external sources. In my case, I use a CDN to serve the files and none of the existing extension were good for my case.

How to use

Extract the files to protected/extension/compressor (or whatever path you want)

Then in your config define the class of clientScript component to use CompressorClientScript

return array(
	'class'=>'ext.compressor.CompressorClientScript',//use whatever location you put the extension
	//the following options are optional and the values defined in this example are the default ones
	'compress'=>true,//wheter to minify and compress the files. Defaults to true
	//see YUICompressor class for more details
		//Insert a line breaks after '}' characters for css files or 
		//Insert a line break after the specified column number for js files
		//Display informational messages and warnings. (useful for cleaning up your JS)
		//Minify only, no symbol obfuscation. Valid for js files
		//Preserve unnecessary semicolons (such as right before a '}'). Valid for js files
		//Disable all the built-in micro optimizations. Valid for js files
		//path to the java binary
		//you can use, for example, 'C:\Program Files (x86)\Java\jre7\bin\java.exe' if you are windows

How to clear the cache?

Just clean up protected/runtime/compressor folder and it will recreate the files

How does it work?

It uses file_get_contents to get the files, so it can be either on your machine or load from external sources

It creates a compressed file in protected/runtime/compress for each page and then publishes it using assetsManager component

For css files, it rewrites the css url's

Uses a modified version of for compression adapted to Yii

Uses a modified version of to rewrite css urls adapted to Yii

2 1
Yii Version: Unknown
License: MIT
Category: Caching
Developed by: Gustavo
Created on: Sep 1, 2013
Last updated: 10 years ago


show all

Related Extensions