This is a work in Progress
HTML Minifier
![Software License][ico-license]
![Coverage Status][ico-scrutinizer]
![Total Downloads][ico-downloads], (*1)
A PHP package to minify HTMLs, Javascripts and CSSs. Supports PSR-4 Autoloader., (*2)
Install
Via Composer, (*3)
``` bash
$ composer require doncadavona/html_minifier, (*4)
## Usage
``` php
use DonCadavona\HtmlMinifier\HtmlMinifier;
// Sample HTML string
$html = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
html {
padding-top: 20px;
}
body {
margin: 0px;
}
</style>
</head>
<body>
<h1>Hello World</h1>
<script>
// This is single-line a comment.
/* This is a
multi-line
comment. */
/**
* This is a doc block comment.
*/
</script>
</body>
</html>
';
// Minify the HTML
echo HtmlMinifier::minify($html);
// <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style type="text/css"> html { padding-top: 20px; } body { margin: 0px; } </style></head><body>
Hello World
</body></html>
// Minify the HTML and remove JavaScripts and CSSs:
echo HtmlMinifier::minify($html, true, true);
// <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body>
Hello World
</body></html>
Change log
Please see CHANGELOG for more information on what has changed recently., (*5)
Testing
bash
$ composer test, (*6)
Contributing
Please see CONTRIBUTING and CONDUCT for details., (*7)
Security
If you discover any security related issues, please email dcadavona@gmail.com instead of using the issue tracker., (*8)
Credits
License
The MIT License (MIT). Please see License File for more information., (*9)