Yii 2.0: yii2-assets-auto-compress

Expansion allows you to combine and optimize js and css files. Dynamically.
10 followers

Automatically compile and merge files js + css + html in yii2 project.

This solution enables you to dynamically combine js and css files to optimize the html page. This allows you to improve the performance of google page speed.

This tool only works on real sites. On the local projects is not working!

Latest Stable Version Total Downloads Reference Status Dependency Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skeeks/yii2-assets-auto-compress "*"

or add

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

How to use

//App config
[
    'bootstrap'    => ['assetsAutoCompress'],
    'components'    =>
    [
    //....
        'assetsAutoCompress' =>
        [
            'class'         => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',
        ],
    //....
    ]
]
//App config with all options
[
    'bootstrap'    => ['assetsAutoCompress'],
    'components'    =>
    [
    //....
        'assetsAutoCompress' =>
        [
            'class'                         => '\skeeks\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
            '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
            '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
 
            'htmlCompress'                  => true,        //Enable compression html
            'noIncludeJsFilesOnPjax'        => true,        //Do not connect the js files when all pjax requests
            'htmlCompressOptions'           =>              //options for compressing output result
            [
                'extra' => false,        //use more compact algorithm
                'no-comments' => true   //cut all the html comments
            ],     
        ],
    //....
    ]
]

Links

Demo (view source code)


skeeks!
SkeekS CMS (Yii2) — fast, simple, effective!
skeeks.com | cms.skeeks.com

Total 8 comments

#19961 report it
skeeks at 2016/10/21 06:00am
Cdn Stuff

19960

@silverspark

It is not yet implemented, but planned. https://github.com/skeeks-semenov/yii2-assets-auto-compress/issues/3

#19960 report it
silverspark at 2016/10/21 05:40am
Cdn Stuff

I am including the cdn css and js files in my assets. for local directory files the js and css are compressed fine. but it is not working with the cdn files. i want to compress cdn files and make a compress so how it is possible with this.

#19935 report it
Web Guru at 2016/08/21 02:02pm
Excellent Extension: but I have faced two issues

Thanks for the amazing extension.

I have faced two issues: 1- when the Javascript contains "@TODO" as a comment it breaks the whole compressed script file 2- If you have special script/CSS for certain browsers (Conditional using ALT) then the Compression will add them always. Suggestion to create multiple files one for the general scripts/CSS and multiple for the conditional CSS/script

#19920 report it
Hikmat Ullah at 2016/07/31 05:04am
SSL certificate problem: unable to get local issuer certificate

On my remote server it gives me below error with details

Level   1
level Detail    LEVEL_ERROR
Category    skeeks\yii2\assetsAuto\AssetsAutoCompressComponent
Log Time    2016-07-31 13:41
Prefix  
Message SSL certificate problem: unable to get local issuer certificate
#19869 report it
skeeks at 2016/05/27 11:45am
Cache

Configure Asset yii2 a manager with the option in your project

...
'components' => [
...
'assetManager' =>
        [
            'appendTimestamp'   => true,
...

Example: https://github.com/skeeks-cms/cms/blob/master/config/main.php#L102

#19868 report it
silverspark at 2016/05/27 10:10am
Jsonu

At my server its always pick the css and js from the old cache. Recent changes will not reflect on website. Even after deleting the all cache from the frontend/web/assets/* directory. so please help i need to show recent changes on website.

#19787 report it
skeeks at 2016/02/23 01:31am
Cache

Yes, the result is cached on some hash. Everything works quickly and optimally for each request.

b75e8b31bfda1686d950c7b8783b53b5.png

3d8caa7df0ef5cb0dd5149f5a5bdebba.png

0e08ffc6d46a1ffa1683c32e8f916d67.png

#19786 report it
Almir at 2016/02/22 04:37pm
Cache

Will this extension create a cache of the minified resources? Or will It make the compression on every request?

Thanks!

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet