dev-master
9999999-devSmart HTML compressor
MIT
The Requires
extension library yii2 html compression
v1
1.0.0.0Smart HTML compressor
MIT
The Requires
extension library yii2 html compression
Wallogit.com
2017 © Pedro Peláez
Smart HTML compressor
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)
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)
Once the extension is installed, simply use it in your code by :, (*6)
In your config file in components:, (*7)
'view' => [
'class' => '\zabachok\htmlcompressor\View',
'compress' => YII_ENV_DEV ? false : true,
'compressCode' => false,
'compressScript' => false
],
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);
},
],
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,
],
];
}
...
}
Using without Yii2., (*10)
$compressor = new HtmlCompressor(); $result = $compressor->make($html);
Smart HTML compressor
MIT
extension library yii2 html compression
Smart HTML compressor
MIT
extension library yii2 html compression