class.compost.php
// I would like to minify the CSS and JS a bit more
I would like to minify the CSS and JS a bit more
I would like to minify the CSS and JS a bit more
public function miniFy($content)
    {
        $find       = array("\r", "\t");
        $replace    = array("\n", "");
        $content    = str_replace($find, $replace, $content);
        $lines      = explode("\n", $content);
        $newContent = array();
        foreach($lines as $lid => $line) {
            $line = trim($line);
            if (substr($line, 0, 2) == "//") continue;
            if ((substr($line, 0, 2) == "/*") AND (substr($line, (strlen($line) - 2)) == "*/")) continue;
            if (stristr($line, '{{SITE_URL}}')) $line = str_replace('{{SITE_URL}}', SITE_URL, $line);
            if (stristr($line, '{{IMG}}')) $line = str_replace('{{IMG}}', IMG, $line);
            if (!empty($line)) {
                $newContent[] = $line;
            }
        }
        $content = implode("\n", $newContent);
        return $content;
    }
public function miniFy ( $ content ) { $ find = array ( " \r " , " \t " ) ; $ replace = array ( " \n " , " " ) ; $ content = str_replace ( $ find , $ replace , $ content ) ; $ lines = explode ( " \n " , $ content ) ; $ newContent = array ( ) ; foreach ( $ lines as $ lid => $ line ) { $ line = trim ( $ line ) ; if ( substr ( $ line , 0 , 2 ) == " // " ) continue ; if ( ( substr ( $ line , 0 , 2 ) == " /* " ) AND ( substr ( $ line , ( strlen ( $ line ) - 2 ) ) == " */ " ) ) continue ; if ( stristr ( $ line , '{{SITE_URL}}' ) ) $ line = str_replace ( '{{SITE_URL}}' , SITE_URL , $ line ) ; if ( stristr ( $ line , '{{IMG}}' ) ) $ line = str_replace ( '{{IMG}}' , IMG , $ line ) ; if ( ! empty ( $ line ) ) { $ newContent [ ] = $ line ; } } $ content = implode ( " \n " , $ newContent ) ; return $ content ; }
I would like to minify the CSS and JS a bit more
I would like to minify the CSS and JS a bit more
// Remove lines with // Comments // Remove lines with /* */ Comments // Site URL in double curleys // IMG url in double curleys // Ensure that the line still has contents