nabu/yii2-compressr

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

v0.0.4 2020-11-03 05:03 UTC

This package is auto-updated.

Last update: 2024-04-29 04:15:47 UTC


README

This extension provides ability to process and combine local assets, thus relieving the developer from having to strictly control what assets used in project and how they organized.

This also makes the page load faster by reducing the page size and reducing the loading of additional files.

Javascript

Extension combines all included .js files in a page, minifies it and include result to the page as a single .js file. This generated file is cached.

All inline javascript is minified and stays in the same place on the page. You can set option to cache this generated parts to prevent multiple generation of the same code parts.

CSS

Like javascript processing, all .css files are minified and included in the page as a single .css file. This generated file is cached.

All inline CSS is combined and minified. Like javascript processing, you can set option to cache this generated code parts.

HTML

Extension also provides ability to minify whole HTML on page. There are two generation strategies used in component:

Install

Add "nabu/yii2-compressr": ">=0.0.4" to composer.json or run

composer require --prefer-dist nabu/yii2-compressr ">=0.0.4"

Usage

[
    'bootstrap' => ['compressr'],
    'components' => [
    ...
        'compressr' =>
        [
            'class' => 'nabu\yii2\compressr\Compressr',

            'enabled' => true,              // enables component. possible use: 'enabled' => YII_ENV_PROD

            'compressJs' => true,           // compress and minify whole javascript on page
            'jsCutComments' => true,        // cut comments in javascript code
            'jsCacheInlineParts' => true,   // cache inline code parts. need the cache to be configured and enabled

            'compressCss' => true,          // compress and minify whole css on page
            'cssCacheInlineParts' => true,  // cache inline code parts. need the cache to be configured and enabled

            'compressHtml' => true,         // compress html
            // possible options: HtmlCompressStrategy::MRCLAY or HtmlCompressStrategy::TYLER
            'htmlCompressStrategy' => \nabu\yii2\compressr\html\HtmlCompressStrategy::MRCLAY,
        ],
    ]
]

Profile

First time heavy page called:

Profile

Subsequent times with caching:

Profile