public function minifyHTML(){
        $buffer = $this->response->getContent();
        if(strpos($buffer,'<pre>') !== false)
        {
            $replace = array(
                '/<!--[^\[](.*?)[^\]]-->/s' => '',
                "/<\?php/"                  => '<?php ',
                "/\r/"                      => '',
                "/>\n</"                    => '><',
                "/>\s+\n</"    				=> '><',
                "/>\n\s+</"					=> '><',
            );
        }
        else
        {
            $replace = array(
                '/<!--[^\[](.*?)[^\]]-->/s' => '',
                "/<\?php/"                  => '<?php ',
                "/\n([\S])/"                => '$1',
                "/\r/"                      => '',
                "/\n/"                      => '',
                "/\t/"                      => '',
                "/ +/"                      => ' ',
                '#^\s*//.+$#m'              => '', // remove single comment in JS
            );
        }
        $buffer = preg_replace(array_keys($replace), array_values($replace), $buffer);
        $this->response->setContent($buffer);
    }
public function minifyHTML(){
        $buffer = $this->response->getContent();
        if(strpos($buffer,'<pre>') !== false)
        {
            $replace = array(
                '/<!--[^\[](.*?)[^\]]-->/s' => '',
                "/<\?php/"                  => '<?php ',
                "/\r/"                      => '',
                "/>\n</"                    => '><',
                "/>\s+\n</"    				=> '><',
                "/>\n\s+</"					=> '><',
            );
        }
        else
        {
            $replace = array(
                '/<!--[^\[](.*?)[^\]]-->/s' => '',
                "/<\?php/"                  => '<?php ',
                "/\n([\S])/"                => '$1',
                "/\r/"                      => '',
                "/\n/"                      => '',
                "/\t/"                      => '',
                "/ +/"                      => ' ',
                '#^\s*//.+$#m'              => '', // remove single comment in JS
            );
        }
        $buffer = preg_replace(array_keys($replace), array_values($replace), $buffer);
        $this->response->setContent($buffer);
    }
public function minifyHTML ( ) { $ buffer = $ this -> response -> getContent ( ) ; if ( strpos ( $ buffer , '<pre>' ) !== false ) { $ replace = array ( '/<!--[^\[](.*?)[^\]]-->/s' => '' , "/<\?php/" => '<?php ' , "/\r/" => '' , "/>\n</" => '><' , "/>\s+\n</" => '><' , "/>\n\s+</" => '><' , ) ; } else { $ replace = array ( '/<!--[^\[](.*?)[^\]]-->/s' => '' , "/<\?php/" => '<?php ' , "/\n([\S])/" => '$1' , "/\r/" => '' , "/\n/" => '' , "/\t/" => '' , "/ +/" => ' ' , '#^\s*//.+$#m' => '' , // remove single comment in JS ) ; } $ buffer = preg_replace ( array_keys ( $ replace ) , array_values ( $ replace ) , $ buffer ) ; $ this -> response -> setContent ( $ buffer ) ; }
Minify the HTML Output

@see http://laravel-tricks.com/tricks/minify-html-output
Minify the HTML Output