Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

WP – Compactar HTML

Esta rotina eu utilizava até hoje no site da PARKEER para compactar o Html a ser exibido pelo WordPress. Embora não tenha maiores aprimoramentos, funciona muito bem.

function start_ob() {
ob_start('pk_compress_html');
}
function end_ob() {
ob_end_flush();
}

function pk_compress_html($output) {

$search = array(
'/\>[^\S ]+/s',     // strip whitespaces after tags, except space
'/[^\S ]+\',     // strip whitespaces before tags, except space
'/(\s)+/s',         // shorten multiple whitespace sequences
'//' // Remove HTML comments
);
$replace = array(
'>',
' '\\1',
''
);
$output = preg_replace($search, $replace, $output);

$output = trim($output);
$output = preg_replace('/^[ \t]*[\r\n]+/m', '', $output);
return $output;
}
add_action('get_header', 'start_ob');
add_action('shutdown', 'end_ob', 999);

O post WP – Compactar Html apareceu primeiro em Minha digital quase vida...



This post first appeared on Minha Digital Quase Vida.., please read the originial post: here

Share the post

WP – Compactar HTML

×

Subscribe to Minha Digital Quase Vida..

Get updates delivered right to your inbox!

Thank you for your subscription

×