Yii安装EClientScript插件扩展实现css,js文件代码压缩合并加载功能

前端之家收集整理的这篇文章主要介绍了Yii安装EClientScript插件扩展实现css,js文件代码压缩合并加载功能前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了Yii安装EClientScript插件扩展实现css,js文件代码压缩合并加载功能分享给大家供大家参考,具体如下:

扩展插件下载地址,解压后复制到/protected/vendor/

main配置文件配置插件,components里面增加

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,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 'optimizeInlineCss' => false,This may case response slower ),

工具类Unit.php放于/protected/vendor/components,类中定义加载方法

getClientScript(); $cs->registerScriptFile($file,$position,$media); } /** *注册CSS文件 */ public function cssFile($file,$media=''){ Yii::app()->getClientScript()->registerCssFile($file,$media); }

模板调用css文件,js文件

//IE6下加载CSS文件 Unit::cssFile('/css/form.css','lte IE 6'); //result to: //注册JS文件, Unit::jsFile('/js/jquery.lazyload.js'); //result to:

猜你在找的PHP相关文章