Page is a not externally linkable
londrum - 9:41 pm on Oct 31, 2007 (gmt 0)
at the very top of your page, above everything else, put and at the very bottom when you view the source code in your browser it should all be crunched up - with the comments stripped out. it will be gzipped up to. you'll probably have to add a few expressions to it though to catch a few more, because everyone's pages are different so i've only put the usual ones in. [edit] i should also mention that it's not a great idea to do this every time that somebody views the page. the best thing to do is do it once and then cache it, and send the cached version to the user.
try wrapping this around your code... <?php
ob_start('ob_gzhandler');
ob_start('compress');
function compress($buffer)
{
$buffer=preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$buffer);
$buffer=str_replace(array("\r\n","\r","\n","\t"),'',$buffer);
return $buffer;
}
?><?php
ob_end_flush();
ob_end_flush();
?>
you have to be careful with in-page javascript though - make sure the lines all end properly because when it removes the line breaks it might break the script