PHPackages                             lastzero/css-optimizer - 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. lastzero/css-optimizer

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

lastzero/css-optimizer
======================

CSS Optimizer - Minifies stylesheets by removing duplicates and combining selectors

v1.0.0(10y ago)04182MITPHPPHP &gt;=5.4

Since Nov 25Pushed 10y agoCompare

[ Source](https://github.com/lastzero/css-optimizer)[ Packagist](https://packagist.org/packages/lastzero/css-optimizer)[ Docs](https://github.com/lastzero/css-optimizer)[ RSS](/packages/lastzero-css-optimizer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (5)Versions (1)Used By (0)

CSS Optimizer for PHP
=====================

[](#css-optimizer-for-php)

[![Build Status](https://camo.githubusercontent.com/5421e5c13cc24ec84d8a221d00e88af52a1b401ee2b3dfb89723b2feac923e3a/68747470733a2f2f7472617669732d63692e6f72672f6c6173747a65726f2f6373732d6f7074696d697a65722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/lastzero/css-optimizer)[![Latest Stable Version](https://camo.githubusercontent.com/44b693fcdb3003916a1c3da548ef154a965ed95f9772bf4f8f53f0fcbc05f69c/68747470733a2f2f706f7365722e707567782e6f72672f6c6173747a65726f2f6373732d6f7074696d697a65722f762f737461626c652e737667)](https://packagist.org/packages/lastzero/css-optimizer)[![License](https://camo.githubusercontent.com/c4283cb7a7cf5a54a64a659928a3c4346aba9a0d8a3305ac3852ededd8a54ed0/68747470733a2f2f706f7365722e707567782e6f72672f6c6173747a65726f2f6373732d6f7074696d697a65722f6c6963656e73652e737667)](https://packagist.org/packages/lastzero/css-optimizer)

Minifies stylesheets by removing duplicates and combining selectors - mostly safe and very efficient. This package was developed as a "quick win" to optimize the CSS of an existing commercial Web site, as the CSS contained many duplicates and similar selectors created by a CSS precompiler. It was published in the hope to help others in the same situation.

*Note: The optimization is performed using simple (and fast) string functions - it's not a real CSS parser. It requires well formed CSS without inline comments (don't worry, you can use the minifyCss() method for that, see usage).*

*Warning: The order of selectors in your CSS does play a role and the "further down" one does in fact win when the specificity values are exactly the same. If your CSS relies on order to work, this optimization will obviously break it. See also [https://en.wikipedia.org/wiki/Cascading\_Style\_Sheets#Specificity](https://en.wikipedia.org/wiki/Cascading_Style_Sheets#Specificity)*

Input:

```
body { foo:bar; too: me; }
body { baz:foo; }
body { foo: new }
div.test { border: 1px solid black; }
div.other { border: 1px solid black}

```

Output:

```
body{baz:foo;foo:new;too:me}div.other,div.test{border:1px solid black}

```

Usage:

```
$optimizer = new \CssOptimizer\Css\Optimizer;

$inputCss = 'body { foo:bar; too: me;} body { baz:foo; } body { foo: new }
div.test { border: 1px solid black; }
div.other { border: 1px solid black} ';

$minifiedCss = $optimizer->minifyCss($inputCss);
$optimizedCss = $optimizer->optimizeCss($minifiedCss);

print_r($optimizer->getCounts());

```

Assetic filter
--------------

[](#assetic-filter)

This library comes with a ready-to-use Assetic filter (for Symfony2). Please use a pre-filter like CssMinFilter.

Usage:

```
$filter = new \CssOptimizer\Assetic\Filter\CssOptimizeFilter;
$asset = new StringAsset($inputCss);
$asset->ensureFilter($filter);
$outputCss = $asset->dump();

```

Composer
--------

[](#composer)

If you are using composer, simply add "lastzero/css-optimizer" to your composer.json file and run `composer update`:

```
"require": {
    "lastzero/css-optimizer": "*"
}

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

3825d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f932b09a688c990f2869e72c771bf0eeb009b264a47a1cf78d54c13f566511da?d=identicon)[lastzero](/maintainers/lastzero)

---

Top Contributors

[![lastzero](https://avatars.githubusercontent.com/u/301686?v=4)](https://github.com/lastzero "lastzero (14 commits)")

---

Tags

symfonycssoptimizationasseticminification

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lastzero-css-optimizer/health.svg)

```
[![Health](https://phpackages.com/badges/lastzero-css-optimizer/health.svg)](https://phpackages.com/packages/lastzero-css-optimizer)
```

###  Alternatives

[sensiolabs/minify-bundle

Assets Minifier (CSS, JS) for Symfony &amp; Minify integration in Asset Mapper

5694.9k1](/packages/sensiolabs-minify-bundle)[mmanos/laravel-casset

An asset management package for Laravel 4.

102.6k](/packages/mmanos-laravel-casset)[rumenx/php-seo

AI-powered, framework-agnostic PHP package for automated SEO optimization. Intelligently generates meta tags, titles, descriptions, and alt texts using configurable AI providers or manual patterns.

102.0k](/packages/rumenx-php-seo)

PHPackages © 2026

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