PHPackages                             salernolabs/collapser - 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. [Image &amp; Media](/categories/media)
4. /
5. salernolabs/collapser

ActiveLibrary[Image &amp; Media](/categories/media)

salernolabs/collapser
=====================

A PHP media collapser with CSS and JS extensions.

v1.0.0(6y ago)0921MITPHPPHP &gt;=7.2

Since May 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/salernolabs/collapser)[ Packagist](https://packagist.org/packages/salernolabs/collapser)[ Docs](http://www.salernolabs.com/)[ RSS](/packages/salernolabs-collapser/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

salernolabs/collapser
=====================

[](#salernolabscollapser)

[![Latest Stable Version](https://camo.githubusercontent.com/0e6315f22dc556c3dec014159c349b9c18174723bf0f1ace608f3c9adca72362/68747470733a2f2f706f7365722e707567782e6f72672f73616c65726e6f6c6162732f636f6c6c61707365722f762f737461626c65)](https://packagist.org/packages/salernolabs/collapser)[![License](https://camo.githubusercontent.com/7b142e36e2c000850f251cd720ddd2111d7d1b01892dbf0801a2157ac197d685/68747470733a2f2f706f7365722e707567782e6f72672f73616c65726e6f6c6162732f636f6c6c61707365722f6c6963656e7365)](https://packagist.org/packages/salernolabs/collapser)[![Build Status](https://camo.githubusercontent.com/85d73910d2ea711401f91a457b0fe1d5284fb1277643e4c500c4c8caa7c76a0e/68747470733a2f2f7472617669732d63692e636f6d2f73616c65726e6f6c6162732f636f6c6c61707365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/salernolabs/collapser)

A PHP media collapser/minifier with CSS and JS extensions. Not really re-inventing the wheel this code was written years ago in my proprietary Chorizo platform. Just moving it out into it's own library. I am fully aware that many developers hate inheritance and protected members/methods. For those offended, I apologize, that's just how this was built.

Usage
-----

[](#usage)

Include this project with composer:

```
composer require salernolabs/collapser

```

### CSS

[](#css)

You can create an instance of the collapser you need, default media (useless), CSS, or Javascript.

```
$collapser = new \SalernoLabs\Collapser\CSS();
$collapser->setDeleteComments(true);

$output = $collapser->collapse($input);

```

If the input CSS is:

```
.helloCSS {
    display: none;
}

#somecss {
    color: #ffffff;
    background: url('/images/whatever.gif');
}

```

The value of $output would be:

```
.helloCSS{display:none;}

```

### Javascript

[](#javascript)

```
$collapser = new \SalernoLabs\Collapser\Javascript();
$collapser->setDeleteComments(true);

$output = $collapser->collapse($input);

```

If the input Javascript is:

```
/**
 Javascript test
 */
var x = 13;

function test(i, j, x)
{
    var output = i + j + x;

    return output;
}

//Run the function in the alert
var detail = test(1, 2, 3);
alert(detail);

```

The value of $output should be:

```
var x=13;function test(i, j, x){var output=i+j+x;return output;}var detail=test(1, 2, 3);alert(detail);

```

Note that it doesn't remove spaces for parameters of functions.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~813 days

Total

2

Last Release

2476d ago

Major Versions

0.1.0 → v1.0.02019-08-03

PHP version history (2 changes)0.1.0PHP &gt;=5.6

v1.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/155974?v=4)[Eric Salerno](/maintainers/ericsalerno)[@ericsalerno](https://github.com/ericsalerno)

---

Top Contributors

[![ericsalerno](https://avatars.githubusercontent.com/u/155974?v=4)](https://github.com/ericsalerno "ericsalerno (2 commits)")

---

Tags

collapsemediaminifyphpphpcssJSmediaCollapser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/salernolabs-collapser/health.svg)

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

###  Alternatives

[dereuromark/media-embed

A PHP library to deal with all those media services around, parsing their URLs and embedding their audio/video content in websites.

182530.3k11](/packages/dereuromark-media-embed)[jkphl/iconizr

A PHP command line tool for converting SVG images to a set of CSS icons (SVG &amp; PNG, single icons and / or CSS sprites) with support for image optimization and Sass output

4869.0k](/packages/jkphl-iconizr)[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[ideatic/tinyfier

Complete suite for compressing, preprocessing, and optimizing HTML/Javascript/CSS and Images.

103.3k](/packages/ideatic-tinyfier)

PHPackages © 2026

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