-
Notifications
You must be signed in to change notification settings - Fork 0
/
optimizeDemo.php
35 lines (26 loc) · 956 Bytes
/
optimizeDemo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<pre><?php
use Webzille\CssParser\CSS;
require "vendor/autoload.php";
$cssFile = "stylesheet.css";
$nodes = CSS::parser($cssFile)->parse()->getNodes();
$optimizer = CSS::optimize($nodes);
// 1. Remove Whitespace and comments
$optimizer->removeWhitespace();
echo "After removing whitespace / Comments:\n";
print_r($optimizer->getModified());
// 2. Remove Duplicates
$optimizer->clearModified()->removeDuplicates();
echo "\n\nAfter removing duplicates:\n";
print_r($optimizer->getModified());
// 3. Convert Longhand to Shorthand
$optimizer->clearModified()->toShorthand();
echo "\n\nAfter converting to shorthand:\n";
print_r($optimizer->getModified());
// 4. Optimize Colors
$optimizer->clearModified()->optimizeColors();
echo "\n\nAfter optimizing colors:\n";
print_r($optimizer->getModified());
// 5. Add Vendor Prefixes
$optimizer->clearModified()->vendorPrefix();
echo "\n\nAfter adding vendor prefixes:\n";
print_r($optimizer->getModified());