承接 abordage/html-min 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

abordage/html-min

最新稳定版本:1.0.0

Composer 安装命令:

composer require abordage/html-min

包简介

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

README 文档

README

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
  • Removing trailing slashes from void elements (HTML5)
  • Skip textarea, pre and script elements
  • Compresses in microseconds. See benchmark and comparison

Requirements

  • PHP 7.4 or higher

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
$htmlMin->removeTrailingSlashes();           // default: false

Remove trailing slashes

In HTML5, void elements (<link>, <meta>, <img>, <br>, etc.) should not have trailing slashes. Enable this option to convert XHTML-style tags like <link ... /> to HTML5-style <link ...>.

$htmlMin->removeTrailingSlashes();
$result = $htmlMin->minify('<link rel="stylesheet" href="style.css" />');
// Result: <link rel="stylesheet" href="style.css">

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.

统计信息

  • 总下载量: 87.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-12