Name | Modified | Size | Downloads / Week |
---|---|---|---|
rawfiles | 2014-07-19 | ||
README.md | 2014-07-21 | 1.6 kB | |
sCSSOptimizer-2.0.zip | 2014-07-21 | 22.0 kB | |
sCSSOptimizer-2.0.tar.gz | 2014-07-21 | 20.4 kB | |
sCSSOptimizer-1.0.zip | 2014-07-19 | 20.1 kB | |
sCSSOptimizer-1.0.tar.gz | 2014-07-19 | 39.0 kB | |
Totals: 6 Items | 103.2 kB | 0 |
sCSSOptimizer
Description
This library is created to compress css files without losing the original css rules. By optimization you can make your css file more secure, because this library makes css more difficult to understand. Basically this library removes whitespaces, comments from css and does the grouping of selectors.
Features
- Removes all comments
- Removes unnecessary whitespaces
- Removes empty style blocks
- Removes last semi-colon
- Removes quote character from url()
- Removes units from value 0
- If possible changes 6-digit hex color value to 3-digit
- Changes rgb() color to hex color value
- If possible changes CSS rules to lower-case
- Removes spaces before '!important'
Usage
- Exmple 1
!/usr/bin/php
$path = "./sample.css"; $original_data = @file_get_contents($path); $scss_optimizer = new sCSSOptimizer($original_data); $optimized_data = $scss_optimizer->getOptimized(); $compression_rate = $scss_optimizer->getCompressionRate(); //now you can save this optimized data to new css file. //or simply you can print that. print($optimized_data);
- Example 2
!/usr/bin/php
$css1 = file_get_contents("./sample1.css"); $css2 = file_get_contents("./sample2.css"); //if you want to compile 2 css files than don't optimize them separatly. //Instead you can do this in a very simple way. $css = $css1.$css2; //join them $scss_optimizer = new sCSSOptimizer($css); //and than parse them $compiled_css = $scss_optimizer->getOptimized();