PHP Classes
elePHPant
Icontem

PHP CSS Optimize: Optimize CSS files removing redundant data

Recommend this page to a friend!
  Info   View files Example   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-02-17 (23 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 188 This week: 7All time: 8,372 This week: 55Up
Version License PHP version Categories
css-optimize 1.0.2GNU General Publi...5PHP 5, Compression, Performance and o...
Description Author

This package can optimize CSS files removing redundant data.

It can take a given CSS file and parse it to be rewritten combining duplicate selectors, extracting duplicate CSS properties and values, minifying the CSS removing white space and comments.

The optimized CSS can be rewritten as CSS or SCSS

Innovation Award
PHP Programming Innovation award nominee
December 2016
Number 6


Prize: PhpStorm IDE 1 year individual subscription
There are many CSS file optimization solutions, but most do not do much more than removing white space and comments.

This package can also optimize CSS files combining duplicated selectors and removing duplicated property values.

Manuel Lemos
  Performance   Level  
Name: Jelle Sebreghts <contact>
Classes: 7 packages by
Country: Belgium Belgium
Innovation award
Innovation award
Nominee: 4x

 

Details

CssOptimizer

Optimizes CSS (combines duplicate selectors, extracts duplicate css properties and values, minifies the css).

Render minified CSS:

$optimizer = new Jelle_S\CssOptimizer\CssOptimizer($css);
file_put_contents('style.min.css', $optimizer->renderMinifiedCSS());

Render SCSS from your css:

$optimizer = new Jelle_S\CssOptimizer\CssOptimizer($css);
file_put_contents('style.scss', $optimizer->renderSCSS());

This code is open source (GPL-3.0), however, if you like this class and you would like to sponsor the developer (me), feel free to paypal.

  Files folder image Files  
File Role Description
Files folder imageexample (3 files)
Files folder imagesrc (1 file, 1 directory)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file example.php Example Example script
  Accessible without login Plain text file style.min.css Data Auxiliary data
  Accessible without login Plain text file style.scss Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageTree (1 file)
  Plain text file CssOptimizer.php Class Class source

  Files folder image Files  /  src  /  Tree  
File Role Description
  Plain text file CssNode.php Class Class source

Downloadcss-optimize-2020-02-17.zip 17KB
Downloadcss-optimize-2020-02-17.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
PHP Array Key Combiner Download .zip .tar.gz Composer dependency. Required
 Version Control Unique User Downloads Download Rankings  
 100%
Total:188
This week:7
All time:8,372
This week:55Up