Yii 1.1: cclientscriptminify

Minify JavaScript and CSS stylesheets for views

Updated to support 1.0.4, now extending cClientScript rather than hacking!

This extension extends CClientScripts by utilizing Minify to minify JavaScript and CSS stylesheets for views.




  • Yii 1.0.3 or above


  1. Copy 'controller' and 'extensions' folder to your project's 'protected' folder
  2. Add following to your config/main.php with in 'components'=>array(, please check out the config/main.example.php
    //URL management
    //Customized CClientScript with Minify
  1. Change any Minify options in controller/MinifyController.php


Use to following methods to register css or js files to be minified.

Yii::app()->clientScript->registerCSSFile($url, $media);

Please note, the $url needs to be absolute path from your document root (where the index.php script is), i.e. '/css/main.css', '/js/myscript.js' etc.

For more Minify tweaks please check out Minify Google Code Page

Change Log

March 24, 2009

  • R2565 supports Yii 1.0.4 (will not work on older version)
  • R2547 Initial release supports 1.0.3

Total 8 comments

#11224 report it
ahmetsulek at 2012/12/28 06:49pm
doesn't work with relative path url

The script removes relative paths for the upper folder e.g




I can successfully work with this script on my remote server because it is served in root path, but on my local server it's in the subfolder e.g http://localhost/my_app

Am I doing something wrong?

#6229 report it
crasx at 2011/12/20 04:13pm

Works great for me in 1.1.8 and saved me lots of time!

#2948 report it
elbek at 2011/03/01 04:57am

It is not work me in yii 1.1.5, illegal character [Прерывать на этой ошибке]

#2401 report it
jackiesun at 2010/12/23 10:27pm
it is not work on yii 1.16

it is not work on yii 1.16

#1060 report it
pangjanne at 2009/12/21 04:08am

follow your tutorial, but the js and css file can't be fined?

#1796 report it
miles at 2009/04/01 10:44am


#1819 report it
unikly at 2009/03/24 11:11pm
Thanks for your comment Jonah

Hi Jonah, thanks for your, we'd like to extend CClientScript, however as YiIFramework stands now 1.0.3 most the variables are private in CClientScript, I believe when 1.0.4 releases, the situation will be different, then we'll update this extension to extend CClientScript rather than a dirty hack.

#1820 report it
jonah at 2009/03/24 08:44pm

This is not good if CClientScript is updated in the core. Instead of copying all the code of CClientScript and duplicating it in CClientScriptMinify, perhaps CClientScriptMinify should just extend CClientScript. In that case, I may very well use this.

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: unikly
  • Category: Caching
  • Votes: +6 / -1
  • Downloaded: 2,141 times
  • Created on: Mar 24, 2009
  • Last updated: Jul 29, 2009