|
Posted by Ciaran on 03/23/07 19:14
Hi again fellas, thank for the replies on this. I'm using a
combination of ob_gzhandler and this php function to compress my
pages. Depending on the page, I'm getting a small increase in server
side time and a huge reduction in the size of the outputted html page
(and bandwidth!). The problem is, as Toby mentioned, the compression
function messes up some things. One thing I've noticed is some of my
javascript functions are breaking because of it so I'm only adding it
on select pages. I love the result so is there any way to stop it
breaking things or is there a better way to get the same effect?
Here's the function:
function compress($buffer){
$search = array('/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s');
$replace = array('>','<','\\1');
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
Cheers,
Ciarán
Navigation:
[Reply to this message]
|