PHP Minify HTML, CSS, JS: Shrink HTML, JavaScript and CSS to take less space

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 203 All time: 8,306 This week: 306Up
Version License PHP version Categories
code-minfier 1.0.3Free for non-comm...5PHP 5, Compression, Parsers
Description Author

This class can minify HTML, JavaScript and CSS to take less space.

It can take a string with either HTML, JavaScript or CSS, and parses it to eliminate unnecessary text.

The class returns as result a a string that is smaller than the original.

Picture of Marco Cesarato
  Performance   Level  
Name: Marco Cesarato <contact>
Classes: 9 packages by
Country: Italy Italy
Innovation award
Innovation award
Nominee: 2x

Details

PHP Minifier

Version: 0.1.5 beta

Github: https://github.com/marcocesarato/PHP-Minifier

Author: Marco Cesarato

Description

This class can minify HTML, JavaScript and CSS to take less space.

It can take a string with either HTML, JavaScript or CSS, and parses it to eliminate unnecessary text.

The class returns as result a a string that is smaller than the original.

Requirements

  • php 4+

Install

Composer

  1. Install composer
  2. Type `composer require marcocesarato/minifier`
  3. Enjoy

Usage

ob_start();

$html = <<<EOD
<html>
<head>
    <title>Hello World</title>
</head>
<body>
    <h1>Hello World</h1>
</body>
</html>
EOD;

echo $html;

$content = ob_get_contents();
ob_clean();

$minifier = new Minifier();
$min_html = $minifier->minifyHTML($content);

echo $min_html;

Methods

Minifier

| Method | Parameters | Description | | ----------- | ----------------------------------- | -------------------------------------------------- | | minifyJS | $javascript<br>return string | Minify Javascript | | minifyCSS | $css<br>return string | Minify CSS | | minifyHTML | $html<br>return string | Minify HTML |

  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Plain text file Minifier.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:203
This week:0
All time:8,306
This week:306Up

For more information send a message to info at phpclasses dot org.