Download the PHP package akankov/html-min without Composer

On this page you can find all versions of the php package akankov/html-min. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package html-min

CI codecov Mutation testing badge Latest Stable Version Monthly Downloads Dependents License

html-min

A fast HTML5 compressor and minifier for PHP. Strips redundant whitespace, comments, optional tags, and default attributes, then sorts what's left so your gzip layer has less work to do.

Built on native \DOMDocument — no third-party DOM dependencies.

Requirements

Installation

Usage

Wrap any block in <nocompress>…</nocompress> to keep its whitespace intact.

Configuration

Every option is a chainable setter. All defaults are shown — the example below reproduces the default configuration.

Each setter returns $this, so you can configure and call minify() in one chain.

Inline CSS and JS minification

By default the contents of <style> and <script> blocks round-trip untouched. Enable the two opt-in toggles to minify them:

The bundled minifiers are zero-dependency and conservative:

Scripts that are not JavaScript are left alone automatically: a <script> whose type is, for example, application/ld+json or text/x-template, and any <script src="…">, passes through unminified.

Using a different minifier

For aggressive minification (identifier renaming, dead-code removal), plug in a third-party tool with setInlineCssMinifier() / setInlineJsMinifier(). Each takes any callable(string): string; pass null to restore the bundled default.

If a bundled minifier throws, the original source is kept and a warning is sent to the PSR-3 logger (when one is set via setLogger()), so a minifier bug can never corrupt the page. User-supplied callables let their exceptions propagate.

Extending

To run your own pass over every element during minification, implement Akankov\HtmlMin\Contract\DomObserver and register it:

Benchmarks

Measured against voku/html-min, wyrihaximus/html-compress, zaininnari/html-minifier, and abordage/html-min on a corpus of real-world HTML pages.

adapter median ms/op geomean ms/op parse failures avg gzipped ratio
akankov/html-min 1.9 1.9 0 / 15 90.7%
akankov/html-min (inline) 2.1 2.5 0 / 15 87.6%
voku/html-min 3.3 3.6 0 / 15 90.7%
wyrihaximus/html-compress 6.0 7.5 0 / 15 87.0%
zaininnari/html-minifier 9.5 8.3 0 / 15 94.8%
abordage/html-min † 0.2 0.2 0 / 15 90.2%

The table above is regenerated by make bench from the latest run. See latest.md for the per-fixture detail (speed, peak memory, gzipped compression ratio, methodology, and non-claims). Reproduce with make bench-install && make bench (requires Docker).

Development

CI runs the full matrix (PHP 8.3 / 8.4 / 8.5) on every push and pull request.

License

MIT — see LICENSE.

Originally authored by Lars Moelleken; maintained in this fork by Alex Kankov.


All versions of html-min with dependencies

PHP Build Version
Package Version
Requires php Version 8.3.* || 8.4.* || 8.5.*
ext-dom Version *
ext-libxml Version *
ext-mbstring Version *
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-middleware Version ^1.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package akankov/html-min contains the following files

Loading the files please wait ...