PHPackages                             grip/trimfilter - 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. grip/trimfilter

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

grip/trimfilter
===============

HTML whitespace filter for PHP

1.0.0(2y ago)01.2kApache-2.0PHP

Since Mar 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/GripOnline/php-trimfilter)[ Packagist](https://packagist.org/packages/grip/trimfilter)[ RSS](/packages/grip-trimfilter/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

HTML whitespace filter for PHP
==============================

[](#html-whitespace-filter-for-php)

This library provides an HTML whitespace filter that you can use to filter out unneeded whitespace from generated HTML. It does not buffer the whole page so it will not hurt your time-to-first-byte (TTFB). Some buffering is required, but you can set the buffer size yourself. A buffer of around 500 bytes is recommended. Contents of `` / `` / `` / `` and comment tags are never trimmed.

Example
=======

[](#example)

This filter turns this

```
>

	Online koploper worden | Grip Online

```

into this:

```
>

Online koploper worden | Grip Online

```

Installing
==========

[](#installing)

The library can be installed using Composer:

```
$ composer require grip/trimfilter
```

Usage
=====

[](#usage)

Example usage with Twig template rendering:

```
$trimFilter = new Grip\HtmlWhitespaceFilter();

ob_start(array($trimFilter, 'filter'), 500);

$template = $twig->load('index.html');
$template->display(['the' => 'variables', 'go' => 'here']);

ob_end_flush();

$trimFilter->endFlush();
```

Caveats
=======

[](#caveats)

This library only works with with single-byte character encodings and UTF-8.

Background
==========

[](#background)

We like our HTML as clean as possible. When working with a template engine (such as Twig), indenting template tags can introduce a whole lot of whitespace in the output. That's why we created this filter in the first place. Other than that, most whitespace in HTML can be seen as 'waste'. It may be true that the excessive whitespace compresses quite well using gzip or brotli, but on the client side it will be sent uncompressed to the HTML parser.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

848d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8860699?v=4)[Erik Hoogeboom](/maintainers/CodeBosw8r)[@CodeBosw8r](https://github.com/CodeBosw8r)

---

Top Contributors

[![CodeBosw8r](https://avatars.githubusercontent.com/u/8860699?v=4)](https://github.com/CodeBosw8r "CodeBosw8r (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/grip-trimfilter/health.svg)

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

###  Alternatives

[wallacemartinss/filament-icon-picker

A beautiful icon picker component for Filament v5 using blade-ui-kit/blade-icons

4723.9k35](/packages/wallacemartinss-filament-icon-picker)[eminos/statamic-tabs

A Statamic addon to be able to group fields into tabs.

1572.4k](/packages/eminos-statamic-tabs)[ffi/var-dumper

List of symfony/var-dumper casters with FFI support

2011.3k4](/packages/ffi-var-dumper)[waconcookiemanagement/wacon-cookie-management

Different cookies are allowed individually. Differentiation into necessary and optional cookies

1114.2k](/packages/waconcookiemanagement-wacon-cookie-management)[dixonstarter/yii2-toggle-column

yii2 toggle column for update in gridview

213.4k](/packages/dixonstarter-yii2-toggle-column)

PHPackages © 2026

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