A PHP media collapser with CSS and JS extensions.

v1.0.0 2019-08-03 21:17 UTC

This package is auto-updated.

Last update: 2024-05-04 07:49:03 UTC


Latest Stable Version License Build Status

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.


Include this project with composer:

composer require salernolabs/collapser


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

$collapser = new \SalernoLabs\Collapser\CSS();

$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:



$collapser = new \SalernoLabs\Collapser\Javascript();

$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);

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.