示例#1
0
    $optimizer = new css_optimizer();
    $optimizer->compress = get('c', true);
    $optimizer->optimize = get('o', true);
    $optimizer->prefixes = get('v', 'webkit,msie,firefox');
    $optimizer->process($css_doc);
    //Generate output
    $out = $css_doc->render($optimizer->compress);
    //Save output
    if (!($fout = array_shift($argv))) {
        echo $out;
    } else {
        //Show stats
        echo 'Optimized in ' . ReadableTime(microtime(true) - $start) . "\n";
        echo 'Input size ' . ReadableSize(strlen($data)) . ' (' . ReadableSize(strlen(gzencode($data, 9))) . ' gziped)' . "\n";
        $ratio = round(strlen($out) / strlen($data), 2) * 100;
        echo 'Output size ' . ReadableSize(strlen($out)) . " ({$ratio}% of original, " . ReadableSize(strlen(gzencode($out, 9))) . ' gziped)' . "\n";
        //Save file
        file_put_contents($fout, $out);
    }
} catch (exception $ex) {
    err($ex->getMessage());
    exit(1);
}
function ReadableTime($time)
{
    if ($time > 60) {
        $min = floor($time / 60);
        $sec = round($time) % 60;
        return "{$min}m {$sec}s";
    } elseif ($time > 1) {
        return round($time, 3) . ' s';
示例#2
0
    ?>
 (<?php 
    echo strlen(gzencode($process_data['source'], 9));
    ?>
 bytes
                            gzipped)
                        </li>
                        <li>Final size: <?php 
    echo ReadableSize(strlen($process_data['css']));
    ?>
 (<?php 
    echo strlen(gzencode($process_data['css'], 9));
    ?>
 bytes gzipped)</li>
                        <li>Difference: <strong><?php 
    printf('%s (%+g%%)', ReadableSize(strlen($process_data['css']) - strlen($process_data['source']), true), round(strlen($process_data['css']) / strlen($process_data['source']), 2) * 100);
    ?>
</strong></li>
                    </ul>
                    <ul>
                        <li>Duration: <?php 
    echo ReadableTime($process_data['execution_time']);
    ?>
</li>
                    </ul>
                </div>
            <?php 
}
?>
        </div>
        <div id="submit">