ubermanu / html-min

HtmlMin is very simple (and very fast) PHP package for minification HTML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HtmlMin: PHP package for HTML minification

Very simple (and very fast) html compression. See benchmark and comparison

HtmlMin

Packagist Version GitHub Tests Status GitHub Code Style Status PHP Version Support License

Features:

  • Removing extra whitespaces
  • Removing html comments
  • Skip textarea, pre and script elements
  • Compresses in microseconds. See benchmark and comparison

Requirements

  • PHP 7.4 - 8.2

Installation

You can install the package via composer:

composer require abordage/html-min

Quick start

<?php

require __DIR__ . '/vendor/autoload.php';

$htmlMin = new Abordage\HtmlMin\HtmlMin();
$result = $htmlMin->minify("<!DOCTYPE html><html>   ...  </html>");

Options

$htmlMin->findDoctypeInDocument(); // default: true
$htmlMin->removeWhitespaceBetweenTags(); // default: true
$htmlMin->removeBlankLinesInScriptElements(); // default: false

Benchmark

See abordage/html-min-benchmark

Testing

composer test:all

or

composer test:phpunit
composer test:phpstan
composer test:phpcsf

or see https://github.com/abordage/html-min/actions/workflows/tests.yml

Feedback

If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

HtmlMin is very simple (and very fast) PHP package for minification HTML

License:MIT License


Languages

Language:PHP 100.0%