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.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0.3 or above
Installation ¶
- Copy 'controller' and 'extensions' folder to your project's 'protected' folder
- Add following to your config/main.php with in 'components'=>array(, please check out the config/main.example.php
//URL management 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'minify/<group:[^\/]+>'=>'minify/index', ), ), //Customized CClientScript with Minify 'clientScript'=>array( 'class'=>'application.extensions.CClientScriptMinify', 'minifyController'=>'/minify', ),
- Change any Minify options in controller/MinifyController.php
Usage ¶
Use to following methods to register css or js files to be minified. ~~~ Yii::app()->clientScript->registerCSSFile($url, $media); Yii::app()->clientScript->registerScriptFile($url); ~~~ 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
sorry
follow your tutorial, but the js and css file can't be fined?
thanks
great
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.
..
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.
it is not work on yii 1.16
it is not work on yii 1.16
ERROR
It is not work me in yii 1.1.5,
illegal character
[Прерывать на этой ошибке] �
Thanks
Works great for me in 1.1.8 and saved me lots of time!
doesn't work with relative path url
The script removes relative paths for the upper folder e.g
[css] background:url('../img/icons/top_twitter.png')
becomes
[css] background:url('/img/icons/top_twitter.png')
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?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.