Wednesday, 21 September 2016

How to minify css and js in Yii2

Minification is the process of removing unnecessary or redundant data without affecting how the resource is processed by the browser - e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so also you can compress your css and js file into one minified resource so it took less time response in server.

yii2-assets-auto-compressPlease add the dependency in your composer file:

"skeeks/yii2-assets-auto-compress": "*"

In your main.php (frontend->config->main.php)

//App config
'bootstrap' => ['assetsAutoCompress'],
'components' =>
'assetsAutoCompress' =>
'class' => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',
'enabled' => true, // false if you don't want to minify the assets
'jsCompress' => true,
'cssFileCompile' => true,
'jsFileCompile' => true,

Now you can can your compile assets on page.

Featured post

How to create dynamic schema in mongodb

Sometime what we need in our application is to create mongodb schema for collection and some of our collection schema are same but names are...

Popular Posts