Minificador HTML
A classe Blumiga\minifier\minifier comprime HTML removendo espaços extras, comentários e otimizando atributos.
HTML original (117 bytes)
<html><head><title> Teste </title></head><body> <h1> Olá Mundo </h1><p> Espaços extras </p></body></html>
HTML comprimido (106 bytes)
<html><head><title> Teste </title></head><body><h1> Olá Mundo </h1><p> Espaços extras </p></body></html>
Economia: 11 bytes (9%)
Uso no controller
use Blumiga\Minifier\Minifier;
$m = new Minifier([
'keep_comments' => false,
'strip_extra_spaces' => true,
]);
// Modo 1: comprimir string
$html = $m->compress($htmlSource);
// Modo 2: buffer de saída
$m->startContent();
// ... HTML
$m->endContent(); // exibe comprimido