Extension plug-in, decompress and copy to/protected/vendor/
Https://github.com/muayyad-alsadi/yii-EClientScript
Main configuration file configuration plug-in, added in components
// Js, css code compression, merge 'clientscript' => array ('class' => 'application. vendor. yii-EClientScript.EClientScript ', 'combinescriptfiles' => TRUE, // By default this is set to true, set this to true if you 'd like to combine the script files 'combinecssfiles' => TRUE, // By default this is set to true, set this to true if you 'd like to combine the css files 'optimizescriptfiles' =>! YII_DEBUG, // @ since: 1.1 'optimizecssfiles' =>! YII_DEBUG, // @ since: 1.1 'optimizeinlinescript' => false, // @ since: 1.6, This may case response slower 'optimizeinlinecs' => false, // @ since: 1.6, This may case response slower ),
The tool class Unit. php is stored in/protected/vendor/components. The class defines the loading method.
/*** Register a JS file */public function jsFile ($ file, $ position = CClientScript: POS_HEAD, $ media = array () {$ cs = Yii :: app ()-> getClientScript (); $ cs-> registerScriptFile ($ file, $ position, $ media );} /*** register the CSS file */public function cssFile ($ file, $ media = '') {Yii: app ()-> getClientScript () -> registerCssFile ($ file, $ media );}
Templates call css files and js files
// Unit: cssFile ('/CSS/form.css', 'lte IE 6') loaded in IE6; // result:
// Register the JS file, Unit: jsFile ('/js/jquery. lazyload. js'); // result to: <script src = "/js/jquery. lazyload. js "> // JS file Unit: jsFile ('/js/common. js', CClientScript: POS_HEAD, array ('Media '=> 'lt IE 9'); // result: <-- [if lt IE 9]> <script src = "/js/common. js ">
?>