2017 © Pedro Peláez
 

library php-minifier

A PHP minifier for HTML, CSS and JS files.

image

dbx123/php-minifier

A PHP minifier for HTML, CSS and JS files.

  • Tuesday, May 22, 2018
  • by david.boyle
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 200 % Grown

The README.md

phpmin-php-minifier

PHPMin is an inline PHP minifier for web resources. It lets you minify HTML4, HTML5, XHTML, CSS and JavaScript files in a single line of code., (*1)

The best bit is its free and open source under the BSD license., (*2)

Installing PHPMin

Installing PHPMin should only take a minute. Here are your choices:, (*3)

  • Install via composer composer require -dev dbx123/php-minifier
  • Hit the 'Download Zip' button on GitHub. https://github.com/dbx123/php-minifier

You can include all the necessary classes by simply including the php-minifier/phpmin.php file., (*4)

require_once ("php-minifier/phpmin.php");

Using PHPMin

How to compress HTML:, (*5)

$minified_html = PHPMin\Minify::html($any_html);

This automatically compresses all inline scripts and stylesheets within the HTML document. Apply a 'data-no-min' attribute to a script or style in your HTML markup to exclude it from minification., (*6)

How to compress CSS:, (*7)

$minified_css = PHPMin\Minify::css($any_css);

How to compress JS:, (*8)

$minified_js = PHPMin\Minify::js($any_js);

Spelling out out:, (*9)


require_once ("php-minifier/phpmin.php"); $html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29"); $minified_html = PHPMin\Minify::html($html); // a 9.38% performance boost - in 3 lines of code!!

There are working examples in the /examples folder of the package., (*10)

PHPMin Performance

  • The compression ratio are typically 5-20% for HTML
  • The compression ratio are typically 5-30% for CSS
  • The compression ratio are typically 5-30% for JavaScript

Even highly optimized sites such as wikipedia.com, github.com and W3Schools.com could reduce the size of their HTML payload using PHPMin html compression., (*11)

Who Made PHPMin ?

The PHPMin project is currently maintained by David Boyle https://github.com/dbx123 The Css compressor is built upon the CssMin package by Joe Scylla. Some code also contributed by Rowan Beentje The JavaScript compressor is built upon Douglas Crockford's JSMin., (*12)

PHPMin Purpose

PHPMin is here to reduce filesizes and page load times, parse css, (*13)

PHPMin Improvements

  • We are relatively new to Composer - and welcome input on package improvements.
  • Removing default values from html tags should reduce HTML file size
  • Allowing HTML fragments rather than whole documents would be ideal.

Unit Test Examples

./vendor/bin/phpunit --configuration phpunit.xml, (*14)

./vendor/bin/phpunit --configuration phpunit.xml --coverage-html coverage-report, (*15)

./vendor/bin/phpunit --configuration phpunit.xml test/CssMin/CssMinTest.php --coverage-html coverage-report, (*16)

./vendor/bin/phpunit --configuration phpunit.xml --filter testCssConvertLevel3AtKeyframesMinifierFilterMinification --coverage-html coverage-report, (*17)

./vendor/squizlabs/php_codesniffer/bin/phpcs --standard=PSR2 src, (*18)

The Versions

22/05 2018

dev-master

9999999-dev https://github.com/dbx123/php-minifier

A PHP minifier for HTML, CSS and JS files.

  Sources   Download

BSD-2-Clause-FreeBSD

The Requires

  • php >=5.3.0

 

The Development Requires

css php javascript html js html5 minify free php5 css3 open source compress min phpmin

22/05 2018

1.0.1

1.0.1.0 https://github.com/dbx123/php-minifier

A PHP minifier for HTML, CSS and JS files.

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

The Development Requires

css php javascript html js html5 minify free php5 css3 open source compress min phpmin