Skip to content

Instantly share code, notes, and snippets.

@envex
Created July 26, 2010 19:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save envex/491083 to your computer and use it in GitHub Desktop.
Save envex/491083 to your computer and use it in GitHub Desktop.
<?php
/*
This file takes all of our css files, compresses and combines them into 1 nice file
This is not my original script, I found and modified it.
I can't remember where I found it though, it's been a while :/
Usage:
<link rel="stylesheet" href="/inc/css/compress.php" type="text/css" media="screen" />
*/
header('Content-type: text/css');
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
ob_start("compress");
//Default CSS
include('reset.css');
include('main.css');
ob_end_flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment