Welcome Guest, Not a member yet? Register   Sign In
Output Minification (Minifying html,css,js) CI 3.x
#6

(05-25-2015, 08:13 AM)nobitacnt Wrote: I have configured
$config['compress_output'] = TRUE;
but view page source remains unchanged,still spaces
Thanks for support
demo: http://hocphp.info/CodeIgniter-3.0.0/index.php/welcome

Try this to remove spaces, line-feeds, etc:

PHP Code:
//==============================================
function _maybe_compress_using_reference( & $result=''$return_result=false )
{
 
   $_SESSION['zzz_after' ''// strlen($result);
 
   $_SESSION['zzz_before'] = strlen($result);
 
   $search = array(
 
       '/\>[^\S ]+/s'  // strip whitespaces after tags, except space
 
       '/[^\S ]+\</s'  // strip whitespaces before tags, except space
 
       '/(\s)+/s'        // shorten multiple whitespace sequences
 
       );
 
   $replace = array(
 
       '>',
 
       '<',
 
       '\\1'
 
       );
 
   $result preg_replace($search$replace$result);
 
   // DOES NOT SHOW ADVERTS ?????
 
   // $hex=array("\x0D","\x0A");
 
   // $result=str_replace($hex,'',$result);

 
   $_SESSION['zzz_after'] = strlen($result);

 
   # Dab on end
 
   if(LOCALHOST): // DABS this on the end after </body></html>
 
     $result str_replace("</body></html>",''$result);

 
     $result .=  '<p class=\'clb\'> ONLY LOCALHOST <br /> Crunched output results:'
 
                   jj.js .'Before: '      number_format($_SESSION['zzz_before'])
 
                   jj.js .'After: &nbsp; 'number_format($_SESSION['zzz_after'])
 
                   jj.js .'Saving: '      number_format($_SESSION['zzz_before'] - $_SESSION['zzz_after']) .' bytes'
 
                   jj.js .'Percent: '     number_format(100 * ($_SESSION['zzz_before'] - $_SESSION['zzz_after']) / $_SESSION['zzz_before']) .' %'
 
               '</p>'
 
               '</body></html>';
 
   endif;

 
 // RETURNED BY REFERENCE
 
 // return $result;
}//endfunc 
Reply


Messages In This Thread
RE: Output Minification (Minifying html,css,js) CI 3.x - by John_Betong - 05-26-2015, 01:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB