Minify Stylesheets Into One Request

<?php
/*
* This function will loop over some stylesheets and minify them into one request
* Place in <head>
*/
function load_head_styles() {
$stylesheets = array(
'bootstrap' => array(
'location' => '/css/bootstrap.css'
),
'theme' => array(
'location' => '/css/custom.css'
)
);

foreach ( $stylesheets as $stylesheet ) :
$css_to_minify[] = $stylesheet['location'];
endforeach;

?><link rel="stylesheet" type="text/css" href="/min/index.php?f=<?php echo implode( ',', $css_to_minify ); ?>"><?php

}
?>

1 Comment

You must be logged in to post a comment.


  1. Sweet, been looking for something like this.