This extension allows you to group files to be combined.
By default CSS files are grouped by "media" value ('' [default], 'all', 'screen', 'print', etc...)
By default JS files are grouped by "position" value (self::POS_HEAD [default], self::POS_END, etc...)
Tested with Yii 1.1.10 (but I see no reason why it would not work for previous Yii versions)
Extract into protected/extensions directory
Edit your config file:
... 'controllerMap'=>array( 'min'=>'ext.ExtACClientScriptMinify.controllers.ExtACClientScriptMinifyController', ), ... 'components'=>array( ... 'clientScript' => array( 'class'=>'ext.ExtACClientScriptMinify.components.ExtACClientScriptMinify', 'controller'=>'min', // the same value set in controllerMap 'debug' => false, // optional: default false 'cache' => 'off', // optional: default 'off' Others values 'file', 'apc', 'memcache' 'cachePath' => '', // for file caching; optional: default '' (Yii::app() -> runtimePath.'/minify_cache'), 'maxAge' => 60*60*24*30, //optional: default 1800 (Cache-Control: max-age value sent to browser (in seconds)) ), ... ),
Simple way: Add files into default group
For CSS
Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style1.css'); Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style2.css');
For JS
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script1.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script2.js');
More groups: Add files into default group and secondary group For CSS
Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style1.css', 'screen'); Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style2.css', 'screen'); Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style3.css', 'screen', 'secondary'); Yii::app()->clientScript->registerCSSFile(Yii::app()->request->baseUrl.'/css/style4.css', 'screen', 'secondary');
Will create two files (style1.css+style2.css and style3.css+style4.css)
For JS
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script1.js', self::POS_HEAD); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script2.js', self::POS_HEAD); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script3.js', self::POS_HEAD, 'secondary'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/script4.js', self::POS_HEAD, 'secondary');
Will create two files (script2.css+script3.css and script3.css+script4.css)
Total 13 comments
this
is not necessary because it is the controllerMap that handles this
the rules in the htaccess file is required only if UrlManager has
What should the route be for this? I tried
but it didn't work. Also you may want to update your documentation, you keep talking about adding min.php to htaccess but you don't provide such file with the release
edit: figured it out. route should be
The problem is always Windows ;)
This weekend I'll create a project with Yii Boilerplate and check on the problem
http://4you-free.com/login on my debian it works correctly
Thx for spend Time
in my minifygroups.var
in my .htaccess
But when i locked in my Network
i have type text/html and the path are wrong F:\xampp\htdocs\white_rabbit_guild\backend\www/white_rabbit_guild
i delete the minfygroups.var and it would be generae a new with the same path
Try this htaccess rule:
RewriteRule ^white_rabbit_guild/backend/www/min/(.*)$ min.php [L,NC]
in every way depends on your configuration
http://localhost/white_rabbit_guild/backend/www/min/2528a03137dca73230d2de0b77681736.css
the js file in the html code generated, what gives (via web)?
oh i see F:\xampp\htdocs\white_rabbit_guild\backend\www/white_rabbit_guild/backend/www/assets/9126dddd/js/bootstrap.bootbox.min.js are wrong path it have to F:\xampp\htdocs\white_rabbit_guild\backend\www/assets/9126dddd/js/bootstrap.bootbox.min.js
JS/CSS files are not written but created on the fly through the file minifyGroups.var. What's in it?
Hello thx for your quick answer but doesnt help me.
Here is my config iam using Yii Boilerplate . The extensions is here my .htaccess i test it with uncomment all others stuff in my .htaccess but there it doesn`t help. Where is the line did you write the files ? i have the minifyGroups.var in my backend/runtime the min folder is in backend/www but no files . Maybe you can help that was great!! Thx
Hi i see in my network files like http://localhost/white_rabbit_guild/backend/www/min/3260db7280b3bc2f646d1b98dfa42e79.js
but the file isnt there
my conf :
Leave a comment
Please login to leave your comment.