abordage/html-min 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

abordage/html-min

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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固