Yii -- EClientScript extension, css, and js File Code compression and Combination Loading

Source: Internet
Author: User

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 ">
 ?>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.