Horje

How to make short all codes of your website

This work for me on php apache wordpress + w total cache + amp put it on the top of php page

index.php
Example: PHP
<?Php
if(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')){
    ob_start ('ob_html_compress'); 
}else{
    ob_start(); 
}
function ob_html_compress($buf) {
$search = array('/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/<!--(.|\s)*?-->/');
$replace = array('>', '<', '\\1', '');
$buf = preg_replace($search, $replace, $buf);
return $buf;

return str_replace(array("\n","\r","\t"),'',$buf);
}
?>

Output should be:

How to make short all codes of your website



Single Articles
How to minify all html code of Your WebsitePHP Cache Tutorial
How to minify html code of Your WebsitePHP Cache Tutorial
How to make short all codes of your websitePHP Cache Tutorial


Related Articles
How to create PHP Simple HTML Cache for a Web Page PHP Cache Tutorial
How to minify all code of Your Website PHP Cache Tutorial

Type:
Php
Category:
Web Tutorial
Sub Category:
PHP Cache Tutorial
Uploaded by:
Admin



Share on: