CSSqueeze: Efficient CSS minification in a single PHP class licensed under Apache 2 and GPLv2.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Tests
class
.scrutinizer.yml
.travis.yml
README.md
composer.json
phpunit.xml

README.md

CSSqueeze: Efficient CSS minification in PHP

License

Build Status Code Coverage Scrutinizer Quality Score

Latest Stable Version Latest Unstable Version

SensioLabsInsight

CSSqueeze …

It's a single PHP class licensed under Apache 2 and GPLv2.

PHP

  • PHP 5.3
  • PHP 5.4
  • PHP 5.5
  • PHP 5.6

Features

  • Remove white space and extra characters
  • whitespace
  • Last semicolon in a statement
  • Measurement units for the values (eg margin: 0px -> margin: 0)
  • Comments (preserving /*! important comments */)
  • Empty statements (eg p {})
  • Use shorthand properties
    • margin
    • padding
    • border
    • outline
    • list-style
    • background (eg instead of background-color)
  • Compress colors
    • Use short notations of hexadecimal colors (Ex: color: # ff6600 becomes color: # f60;). Use colors supported in CSS 2 whose name is shorter than the hexadecimal.
  • Sorting CSS properties
  • Merge properties
  • merge rules if required
  • @import CSS only if file exists
  • @media queries CSS

Compare few minifiers

ranking is by after compression and gzipped, after compression

file compressed : 002/002.css from csszengarden.com

  origin after compression saved compression ratio after compression and gzipped compression and gzip ratio
CSSqueeze 5547 2862 2685 48,40% 919 83,43%
csscompressor 5547 2863 2684 48,39% 920 83,41%
YUI 5547 2902 2645 47,68% 920 83,41%
excssive.com 5547 2861 2686 48,42% 924 83,34%
cssminifier.com 5547 2875 2672 48,17% 925 83,32%
cssdrive.com 5547 2964 2583 46,57% 934 83,16%
minifycss.com 5547 2894 2653 47,83% 936 83,13%

Todo

  • embed image and/or sprites background-image
  • Add vendor prefix
  • More shorthands
  • rgba(
  • change hack throught html class

Vendors Prefix

  • -o- Opera
  • -moz- Gecko (Mozilla)
  • -webkit- Webkit (Chrome, Safari, Android...)
  • -ms-/mso- (Internet Explorer)
  • -khtml- KHTML (Konqueror)