ianbogda/cssqueeze

Efficient CSS minification in PHP

1.3.0 2014-01-28 13:50 UTC

This package is not auto-updated.

Last update: 2024-12-17 03:31:00 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

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)