ianbogda/cssqueeze

Efficient CSS minification in PHP

Installs: 203

Dependents: 0

Stars: 9

Watchers: 5

Forks: 1

Language: PHP

1.3.0 2014-01-28 13:50 UTC

README

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)