Minifier Class

Files

/engine/class.www-minifier.php

Introduction

Minifier is used to minify text data without breaking functionality of that text. This is useful to be applied to JavaScript, CSS Stylesheets, HTML and XML formats for purposes of making the file size smaller, thus increasing the performance when file is transferred over HTTP.

You should be careful when using minifier however, since it might break functionality under some instances, so it is always good to test before deploying minified resources to live systems.

Using Minifier class

To use Minifier class, it is recommended to load Minifier class and then call the static methods of that class. For example, to minify JavaScript text content, you can do as follows:

	
	require('/engine/class.www-minifier.php');
	$minifiedJavaScript=WWW_Minifier::minifyJS($originalJavaScript);
	

Minifier Class Parameters

Minifier class implements no parameters.

Minifier Class Methods

public static function minifyCSS($data)

This method removes comments, tabs, spaces, new-lines and various other spaces from text. It assumes that text is in a CSS-like format.

public static function minifyJS($data)

This method removes comments, tabs, spaces, new-lines and various other spaces from text. It assumes that text is in a JavaScript-like format.

public static function minifyHTML($data)

This method removes comments, tabs, spaces, new-lines and various other spaces from text. It assumes that text is in a HTML-like format.

public static function minifyXML($data)

This method removes comments, tabs, spaces, new-lines and various other spaces from text. It assumes that text is in a XML-like format.