Welcome Guest, Not a member yet? Register   Sign In
how to compress the html/js/style files in codeigniter ???
#4

[eluser]John_Betong[/eluser]
 
With regards to compression I tried changing this setting ./config/config.php
Code:
config['compress_output'] = TRUE; // FALSE; // default
The result was that it produces a blank page...
 
 
I investigated further in the forum and came across this code that I adapted for my own benefit. On average it reduces the $result by about 10%.
Code:
if (LOCALHOST) // DO NOT compress result
{
    // DO NOT COMPRESS
}else{
  $_SESSION['output_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);

        $result .= sprintf('%6.3f', $_SESSION['zzz_after'] / $_SESSION['zzz_before']);
    $_SESSION['output_after'] = strlen($result);
}//endcompress

echo $result;
&nbsp;
I am curious to know what happens to the css/js files that are referenced in the $result. Are they expanded then compressed or does the reference get passed through to the browser where it is finally loaded?
&nbsp;
&nbsp;
&nbsp;


Messages In This Thread
how to compress the html/js/style files in codeigniter ??? - by El Forum - 09-07-2009, 09:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB