yii-html-compactor Filter to compress the HTML output

  1. Requirements
  2. Installation
  3. Usage
  4. Inspiration

The extension is a filter to compress the HTML output - to reduce bandwidth.

The filter offers two compression methods:

  • GZIP compression
  • Trim leading white space and blank lines from HTML output. But does not affect pre, script or textarea blocks.

Heads up: The GZIP compression is turned off for old buggy IE's (< IE7).

Requirements

  • Yii 1.1.10 or above...(could work with older versions)
  • tested with IE7-9, Firefox 13, Chromium, Safari 5.1

Installation

  • Extract the release file under protected/filters
  • put in a controller code blocks like the following...

Usage

See the following code example:

GZIP for all actions

/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
            array(
                'application.filters.html.ECompressHtmlFilter',
                'gzip'            => (YII_DEBUG ? false : true),
                'doStripNewlines' => (YII_DEBUG ? false : true),
                'actions' => '*'
            ),
		);
	}

GZIP only for index & admin action in controller with CRUD actions

/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
            array(
                'application.filters.html.ECompressHtmlFilter',
                'gzip'            => (YII_DEBUG ? false : true),
                'doStripNewlines' => (YII_DEBUG ? false : true),
                'actions' => 'index, admin'
            ),
		);
	}

Trim leading white space, blank lines & new lines from HTML output for all action

/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
            array(
                'application.filters.html.ECompressHtmlFilter',
                'gzip'    => false,
                'actions' => 'ALL'
            ),
		);
	}

Nothing will compressed

/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
            array(
                'application.filters.html.ECompressHtmlFilter',
            ),
		);
	}

Inspiration

6 0
16 followers
1 756 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: volkmar
Created on: Jul 22, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions