I need to compress my css files and presently it takes lot of time for loading and i also got multiple http request warning.
So i found this on code.google.com Code.google.com example program link
according to them,i need to specify all css links in a php file instead of my html and call that php once in html.So the http request issue will get solved and that code from google compress the css file also.
Instead of
link rel="stylesheet" type="text/css" href="/css/main.css" />
link rel="stylesheet" type="text/css" href="/css/menu.css" />
link rel="stylesheet" type="text/css" href="/css/blog.css" />
link rel="stylesheet" type="text/css" href="/css/box.css" />
link rel="stylesheet" type="text/css" href="/css/form.css" />
link rel="stylesheet" type="text/css" href="/css/profile.css" />
link rel="stylesheet" type="text/css" href="/css/page.css" />
link rel="stylesheet" type="text/css" href="/css/gallery.css" />
Your write
link rel="stylesheet" type="text/css" href="/css/css_include.php" />
This is the php code format
<?php
function compress($buffer)
{
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
$handle = opendir(".");
header ('Content-type: text/css');
header ("Cache-control: public");
header ("Vary: Accept-Encoding");
header ("Content-Encoding: gzip");
ob_start("ob_gzhandler");
while (false != ($file = readdir($handle)))
{
if (strpos($file,".css") !== FALSE)
{
echo compress (file_get_contents($file));
}
}
?>
But My question is how can i add files in that php ???I mean where should i add the css paths in this php?