abbas13375 / yii2-assets-auto-compress
自动编译和合并yii2项目中js + css + html文件
1.4.3.3
2020-11-05 10:48 UTC
Requires
- mrclay/minify: ^3.0.3
- natxet/cssmin: ^3.0.6
- tedivm/jshrink: ^1.3.0
- yiisoft/yii2: ^2
- yiisoft/yii2-httpclient: ^2
README
此解决方案允许您动态组合js和css文件以优化html页面。这有助于提高谷歌页面速度的性能。
此工具仅适用于真实网站。在本地项目中不起作用!
安装
安装此扩展的首选方式是通过 composer。
运行
php composer.phar require --prefer-dist abbas13375/yii2-assets-auto-compress "*"
或添加
"abbas13375/yii2-assets-auto-compress": "*"
如何使用
//App config [ 'bootstrap' => ['assetsAutoCompress'], 'components' => [ //.... 'assetsAutoCompress' => [ 'class' => '\abbas13375\yii2\assetsAuto\AssetsAutoCompressComponent', ], //.... ] ]
//App config with all options [ 'bootstrap' => ['assetsAutoCompress'], 'components' => [ //.... 'assetsAutoCompress' => [ 'class' => '\abbas13375\yii2\assetsAuto\AssetsAutoCompressComponent', 'enabled' => true, 'readFileTimeout' => 3, //Time in seconds for reading each asset file 'jsCompress' => true, //Enable minification js in html code 'jsCompressFlaggedComments' => true, //Cut comments during processing js 'cssCompress' => true, //Enable minification css in html code 'cssFileCompile' => true, //Turning association css files 'cssFileCompileByGroups' => false //Enables the compilation of files in groups rather than in a single file. Works only when the $cssFileCompile option is enabled 'cssFileRemouteCompile' => false, //Trying to get css files to which the specified path as the remote file, skchat him to her. 'cssFileCompress' => true, //Enable compression and processing before being stored in the css file 'cssFileBottom' => false, //Moving down the page css files 'cssFileBottomLoadOnJs' => false, //Transfer css file down the page and uploading them using js 'jsFileCompile' => true, //Turning association js files 'jsFileCompileByGroups' => false //Enables the compilation of files in groups rather than in a single file. Works only when the $jsFileCompile option is enabled 'jsFileRemouteCompile' => false, //Trying to get a js files to which the specified path as the remote file, skchat him to her. 'jsFileCompress' => true, //Enable compression and processing js before saving a file 'jsFileCompressFlaggedComments' => true, //Cut comments during processing js 'noIncludeJsFilesOnPjax' => true, //Do not connect the js files when all pjax requests when all pjax requests when enabled jsFileCompile 'noIncludeCssFilesOnPjax' => true, //Do not connect the css files when all pjax requests when all pjax requests when enabled cssFileCompile 'htmlFormatter' => [ //Enable compression html 'class' => 'abbas13375\yii2\assetsAuto\formatters\html\TylerHtmlCompressor', 'extra' => false, //use more compact algorithm 'noComments' => true, //cut all the html comments 'maxNumberRows' => 50000, //The maximum number of rows that the formatter runs on //or 'class' => 'abbas13375\yii2\assetsAuto\formatters\html\MrclayHtmlCompressor', //or any other your handler implements abbas13375\yii2\assetsAuto\IFormatter interface //or false ], ], //.... ], ];
链接
演示(查看源代码)
截图
SkeekS CMS (Yii2) — 快速、简单、有效!
skeeks.com | cms.skeeks.com