skeeks/yii2-assets-auto-compress Automatically compile and merge files js + css + html in yii2 project

frameworkassetsjscssappskeekssxautoassets

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

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
            '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'         => 'skeeks\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' => 'skeeks\yii2\assetsAuto\formatters\html\MrclayHtmlCompressor',

                //or any other your handler implements skeeks\yii2\assetsAuto\IFormatter interface

                //or false
            ],
        ],
        //....
    ],
];

Links

Demo (view source code)

Screenshot

SkeekS CMS admin panel


SkeekS CMS admin panel


SkeekS CMS admin panel


SkeekS CMS admin panel


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

Changelog

CHANGELOG

1.4.5

  • php 8.2

1.4.4

  • Variables minifier filter default false

1.4.3.2

  • Fixed option noIncludeJsFilesOnPjax = true
  • Add option noIncludeCssFilesOnPjax = true — Do not connect the css files when all pjax requests when enabled cssFileCompile

1.4.3.1

1.4.3

  • New option cssFileCompileByGroups — Enables the compilation of files in groups rather than in a single file. Works only when the $cssFileCompile option is enabled
  • New option jsFileCompileByGroups — Enables the compilation of files in groups rather than in a single file. Works only when the $jsFileCompile option is enabled

1.4.2

1.4.1

  • Logs
  • JsMinFormatter
  • CssMinFormatter

1.4.0

  • Use new config!

Old config :

'assetsAutoCompress' => [
    'class'   => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',

    'htmlCompress'                  => true, //Deprecated!!!       
    'htmlCompressOptions'           =>       //Deprecated!!!       
    [
        'extra' => false,      
        'no-comments' => true 
    ],   
],

New config:

'assetsAutoCompress' => [
    'class'   => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',
    'htmlFormatter' => [
        //Enable compression html
        'class'         => 'skeeks\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' => 'skeeks\yii2\assetsAuto\formatters\html\MrclayHtmlCompressor',

        //or any other your handler implements skeeks\yii2\assetsAuto\IFormatter interface

        //or false
    ],
],
  • New option maxNumberRows in TylerHtmlCompressor — the maximum number of rows that the formatter runs on
  • Fixed double html conversion
  • Created skeeks\yii2\assetsAuto\formatters\html\MrclayHtmlCompressor
  • Created skeeks\yii2\assetsAuto\formatters\html\TylerHtmlCompressor
  • Added htmlFormatter config option
  • Deprecated htmlCompressOptions config option
  • Deprecated htmlCompress config option
  • Using IFormatter interface
  • Using stable versions of dependencies

1.3.1.2

  • Fixed local read files

1.3.1.1

  • Fixed webroot setting

1.3.1

1.3.0

1.2.3.1

  • http_code 200

1.2.3

  • Do not connect the js files when all pjax requests.

1.2.2

1.2.1

  • Html compression by default no extra

1.2.0

  • Added html compression

1.1.2

1.1.1

  • fixed bug download css from remoute server

1.1

  • Removed unnecessary settings preloader

1.0.4

  • Added timeout on file reading

1.0.3

  • Ability to insert CSS using js
  • Added ability to enable preloader
  • It adds the ability to transfer files, css bottom of the page

1.0.2

  • Pjax requests should not be exclusion
  • Update composer (use mrclay/minify)

1.0.1

  • Add setting cssCompress

1.0.0

  • Stable release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.4.5.2 is the latest of 30 releases



BSD-3-Clause license
Stats
158 github stars & 43 github forks
227 downloads in the last day
5319 downloads in the last 30 days
344985 total downloads