2017 © Pedro Peláez
 

yii2-extension yii2-htmlcompressor

Smart HTML compressor

image

zabachok/yii2-htmlcompressor

Smart HTML compressor

  • Wednesday, June 1, 2016
  • by zabachok
  • Repository
  • 1 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

Compressing HTML before submit to client

HTML compressor. This component allows you to compress the HTML-code. If you want it is possible not to compress the contents in script and code tags. На русском, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist zabachok/yii2-htmlcompressor "*"

or add, (*4)

"zabachok/yii2-htmlcompressor": "*"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by :, (*6)

By View component

In your config file in components:, (*7)

'view' => [
    'class' => '\zabachok\htmlcompressor\View',
    'compress' => YII_ENV_DEV ? false : true,
    'compressCode' => false,
    'compressScript' => false
],

By event

In your config file in components:, (*8)

'response' => [
    'on beforeSend' => function ($event)
    {
        /** @var $event yii\base\ViewEvent */
        $response = $event->sender;
        $compressor = new \zabachok\htmlcompressor\HtmlCompressor(false, false);
        $response->data = $compressor->make($response->data);
    },
],

By behavior

If you already have custom View component, you can use behavior., (*9)

class View extends \yii\web\View
{
    public function behaviors()
    {
        return [
            [
                'class' => HtmlCompressorBehavior::className(),
                'compress' => true,
                'compressScript' => true,
                'compressCode' => true,
            ],
        ];
    }
    ...
}

Withoit Yii2

Using without Yii2., (*10)

$compressor = new HtmlCompressor();
$result = $compressor->make($html);

The Versions

01/06 2016

dev-master

9999999-dev

Smart HTML compressor

  Sources   Download

MIT

The Requires

 

extension library yii2 html compression

01/06 2016

v1

1.0.0.0

Smart HTML compressor

  Sources   Download

MIT

The Requires

 

extension library yii2 html compression