CSS and Javascript

Consider the following link to minify Javascript/CSS files:


Tell Apache to deliver HTML with GZip - this generally reduces the response size by about 70%. (If you use Apache, the module configuring gzip depends on your version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate.)

Accept-Encoding: gzip, deflate

Content-Encoding: gzip

Use the following snippet to remove white-spaces from the HTML with the help ob_start's buffer:


function sanitize_output($buffer) {

    $search = array(
        '/>[^S ]+/s',     // strip whitespaces after tags, except space
        '/[^S ]+</s',     // strip whitespaces before tags, except space
        '/(s)+/s',         // shorten multiple whitespace sequences
        '/<!--(.|s)*?-->/' // Remove HTML comments

    $replace = array(

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;


  • 0
Reply Report