abordage/html-min

Very simple (and very fast) PHP package for HTML minification

0.2.2 2024-02-28 14:49 UTC

README

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.