Skip to content

Instantly share code, notes, and snippets.

@noyb34
Created April 17, 2013 01:00
Show Gist options
  • Save noyb34/5400955 to your computer and use it in GitHub Desktop.
Save noyb34/5400955 to your computer and use it in GitHub Desktop.
This PHP code combine all my css files into one therefore reducing the number of http request to the server
<?php // combine all CSS files
header('Content-type: text/css');
$path_to_css = '/css'; // edit path to css directory
function get_files($dir = '.', $sort = 0) {
$files = scandir($dir, $sort);
$files = array_diff($files, array('.', '..'));
return $files;
}
$files = get_files($path_to_css, 1);
foreach($files as $file) {
include_once($path_to_css . '/' . $file);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment