Constants

NL

NL

TOKEN

TOKEN

COMMENT

COMMENT

CLASSCOLON

CLASSCOLON

QUERY_FRACTION

QUERY_FRACTION

Properties

$comments

$comments : 

Type

$preserved_tokens

$preserved_tokens : 

Type

$memory_limit

$memory_limit : 

Type

$max_execution_time

$max_execution_time : 

Type

$pcre_backtrack_limit

$pcre_backtrack_limit : 

Type

$pcre_recursion_limit

$pcre_recursion_limit : 

Type

$raise_php_limits

$raise_php_limits : 

Type

Methods

__construct()

__construct(boolean|integer  $raise_php_limits = TRUE) 

Parameters

boolean|integer $raise_php_limits

If true, PHP settings will be raised if needed

run()

run(string  $css = '', integer|boolean  $linebreak_pos = FALSE) : string

Minify a string of CSS

Parameters

string $css
integer|boolean $linebreak_pos

Returns

string

set_memory_limit()

set_memory_limit(integer|string  $limit) 

Sets the memory limit for this script

Parameters

integer|string $limit

set_max_execution_time()

set_max_execution_time(integer|string  $seconds) 

Sets the maximum execution time for this script

Parameters

integer|string $seconds

set_pcre_backtrack_limit()

set_pcre_backtrack_limit(integer  $limit) 

Sets the PCRE backtrack limit for this script

Parameters

integer $limit

set_pcre_recursion_limit()

set_pcre_recursion_limit(integer  $limit) 

Sets the PCRE recursion limit for this script

Parameters

integer $limit

do_raise_php_limits()

do_raise_php_limits() 

Try to configure PHP to use at least the suggested minimum settings

minify()

minify(string  $css, integer|boolean  $linebreak_pos) : string

Does bulk of the minification

Parameters

string $css
integer|boolean $linebreak_pos

Returns

string

extract_data_urls()

extract_data_urls(string  $css) : string

Utility method to replace all data urls with tokens before we start compressing, to avoid performance issues running some of the subsequent regexes against large strings chunks.

Parameters

string $css

Returns

string

compress_hex_colors()

compress_hex_colors(string  $css) : string

Utility method to compress hex color values of the form #AABBCC to #ABC or short color name.

DOES NOT compress CSS ID selectors which match the above pattern (which would break things). e.g. #AddressForm { ... }

DOES NOT compress IE filters, which have hex color values (which would break things). e.g. filter: chroma(color="#FFFFFF");

DOES NOT compress invalid hex values. e.g. background-color: #aabbccdd

Parameters

string $css

Returns

string

replace_string()

replace_string(  $matches) 

Parameters

$matches

replace_colon()

replace_colon(  $matches) 

Parameters

$matches

replace_calc()

replace_calc(  $matches) 

Parameters

$matches

rgb_to_hex()

rgb_to_hex(  $matches) 

Parameters

$matches

hsl_to_hex()

hsl_to_hex(  $matches) 

Parameters

$matches

lowercase_pseudo_first()

lowercase_pseudo_first(  $matches) 

Parameters

$matches

lowercase_directives()

lowercase_directives(  $matches) 

Parameters

$matches

lowercase_pseudo_elements()

lowercase_pseudo_elements(  $matches) 

Parameters

$matches

lowercase_common_functions()

lowercase_common_functions(  $matches) 

Parameters

$matches

lowercase_common_functions_values()

lowercase_common_functions_values(  $matches) 

Parameters

$matches

lowercase_properties()

lowercase_properties(  $matches) 

Parameters

$matches

hue_to_rgb()

hue_to_rgb(  $v1,   $v2,   $vh) 

Parameters

$v1
$v2
$vh

round_number()

round_number(  $n) 

Parameters

$n

clamp_number()

clamp_number(  $n,   $min,   $max) 

Parameters

$n
$min
$max

index_of()

index_of(string  $haystack, string  $needle, integer  $offset) : integer

PHP port of Javascript's "indexOf" function for strings only Author: Tubal Martin http://blog.margenn.com

Parameters

string $haystack
string $needle
integer $offset

index (optional)

Returns

integer

str_slice()

str_slice(string  $str, integer  $start, integer|boolean  $end = FALSE) : string

PHP port of Javascript's "slice" function for strings only Author: Tubal Martin http://blog.margenn.com Tests: http://margenn.com/tubal/str_slice/

Parameters

string $str
integer $start

index

integer|boolean $end

index (optional)

Returns

string

normalize_int()

normalize_int(mixed  $size) : integer

Convert strings like "64M" or "30" to int values

Parameters

mixed $size

Returns

integer