yanli0303 / yii-minify-client-script
This package is abandoned and no longer maintained.
No replacement package was suggested.
A PHP Yii framework extension to minify JavaScript and CSS files for a web page.
0.2
2015-03-04 10:08 UTC
Requires
- php: >=5.3
- yiisoft/yii: >=1.1.13 | <2
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is not auto-updated.
Last update: 2020-01-24 15:45:57 UTC
README
By Yan Li
A PHP Yii framework extension to minify JavaScript and CSS files for a web page.
How does it work?
- Minify each JavaScript and CSS files before deployment (during build stage):
- For each JavaScript/CSS file we have, generated a minified version in same directory, and name it with a .min suffix;
- e.g. Minified version of
~/src/css/style.css
should be named as~/src/css/style.min.css
- Concatenate the JavaScript/CSS files required on the page at run-time
Usage
- Create a new extension directory for your Yii application:
~/protected/extensions/minify
- Download both src/MinifyClientScript.php and LICENSE.md, put them into
~/protected/extensions/minify
- Update your Yii application configuration file(usually named
/protected/config/main.php
) and replace the Yii CClientScript withMinifyClientScript
- Before deploying, minify the individual JavaScript and CSS files:
- You can do it with Ant-MinifyJsCss
- Pack your application sources and deploy
Sample Yii application configuration file:
return array( 'basePath' => __DIR__ . '/..', 'name' => 'Your App Name', 'preload' => array('log'), 'import' => array( 'application.models.*', 'application.components.*', 'application.extensions.*' ), 'clientScript' => array( 'class' => 'ext.minify.MinifyClientScript', 'minify' => !YII_DEBUG, // Disable minifying while developing // put all js files before end </body> tag // note this setting won't affect css files, they will be put in <head> 'coreScriptPosition' => CClientScript::POS_END, 'packages' => array( 'home_page' => array( 'baseUrl' => '', 'js' => array( 'bower_components/jquery/jquery.js', 'bower_components/angular/angular.js', 'bower_components/bootstrap/dist/js/bootstrap.js', 'js/home/home_index.js' ), 'css' => array( 'bower_components/bootstrap/dist/css/bootstrap.css', 'css/home/home_index.css' ) ) ) ) );
NOTE
It requires sticky session from load balance server, otherwise you'll encounter HTTP 404 problems.
Alternatives
- EClientScript: https://github.com/muayyad-alsadi/yii-EClientScript