PHPackages                             codealfa/minify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. codealfa/minify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codealfa/minify
===============

An extremely fast PHP based minification library for Javascript, CSS, Html and Json scripts using Regex Parsing

2.1.0(1y ago)03201GPL-3.0-or-laterJavaScriptPHP &gt;=7.0

Since Oct 8Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/codealfa/minify)[ Packagist](https://packagist.org/packages/codealfa/minify)[ RSS](/packages/codealfa-minify/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

JCH Minify
==========

[](#jch-minify)

An extremely fast PHP based minification library for Javascript, CSS, Html and Json scripts using Regex Parsing

Installation
------------

[](#installation)

Run the following command to use the library in your projects:

```
composer require codealfa/minify

```

Basic Usage
-----------

[](#basic-usage)

You can use any of the minifiers in the following way:

```
use CodeAlfa\Minify\Js;

$sMinifiedJs = Js::optimize($sOriginalJs);
```

Html Minifier Options
---------------------

[](#html-minifier-options)

The HTML minifier takes the following options:

- `cssMinifier` (default `null`): Callback function to minify the contents of in-page `` elements.
- `jsMinifier` (default `null`): Callback function to minify the contents of in-page `` elements.
- `jsonMinifier` (default `null`): Callback function to minify the contents of in-page json contents. The Html Minifer will inspect the `type` attribute of `script` contents to determine if it's javascript or json.
- `minifyLevel` (default `0`): Determine the minification level of the HTML. Possible values are:
    - `0`: Runs of whitespace outside elements are reduced to one whitespace, if a line feed is included it will be preserved. (HTML comments are not removed). In-page scripts and styles are minified if callback functions were provided.
    - `1`: HTML comments are removed, along with whitespaces around block elements. Unnecessary whitespaces inside elements and around attributes are removed.
    - `2`: Redundant attributes eg., `type="text/javascript"` are removed. Quotes are removed from selected attributes if the isHtml5 option is set to `true`.
- `isXhtml` (default `false`): HTML content treated as XHTML1.0. In-page javascript content with characters that needs escaping in XML will be surrounded by `/**/`
- `isHtml5` (default `false`): If set to `true` then when `minifyLevel` is set to `2`, quotes are removed from attibutes if they don't contain characters that necessitates quoting.

**Example:**

```
use CodeAlfa\Minify\Html;

$aOptions = array(
    'cssMinifier' => array('CodeAlfa\Minify\Css', 'optimize'),
    'jsMinifier'  => array('CodeAlfa\Minify\Js', 'optimize'),
    'minifyLevel' => 2,
    'isHtml5'     => true
);

$sMinifiedHtml = Html::optimize($sOriginalHtml, $aOptions);
```

License
-------

[](#license)

GPL-3.0 or later

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~363 days

Total

5

Last Release

592d ago

Major Versions

1.0.2 → 2.0.02021-06-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a4ff3c397fe055d711ae5f763439c0db8c44fe0ff2c01b1dc28c00b51b8ef0a?d=identicon)[codealfa](/maintainers/codealfa)

---

Top Contributors

[![codealfa](https://avatars.githubusercontent.com/u/10180134?v=4)](https://github.com/codealfa "codealfa (53 commits)")

### Embed Badge

![Health badge](/badges/codealfa-minify/health.svg)

```
[![Health](https://phpackages.com/badges/codealfa-minify/health.svg)](https://phpackages.com/packages/codealfa-minify)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
