/** * Compressor libraries */ public function _compressor($language, $code = "") { $root = realpath(__DIR__); require_once $root . "/min-css.php"; require_once $root . "/jshrink.php"; require_once $root . "/html-compress.php"; if (mb_strlen($code, '8bit') > 500000) { return $code; } else { if ($language == "css") { /** * What kind of css stuff should it convert */ $minifier = new MatthiasMullie\Minify\CSS(); $minifier->add($code); return $minifier->minify(); } elseif ($language == "js") { return \JShrink\Minifier::minify($code); } elseif ($language == "html") { $html = new Tinyfier_HTML_Tool(); if ($this->curOptions['compress']["minInline"]) { return $html->process($code, array("compress_all" => true)); } else { return $html->process($code, array("compress_all" => false)); } } } }
/** * Compress each languages * @param string $language The language of source code * @param string $code The source code * @return string Compressed code */ public static function _compressor($language, $code = "", $minInline) { /** * Skip if file size is > 500KB */ if (mb_strlen($code, '8bit') > 500000) { return $code; } else { if ($language == "css") { /** * What kind of css stuff should it convert */ $minifier = new MatthiasMullie\Minify\CSS(); $minifier->add($code); return $minifier->minify(); } else { if ($language == "js") { return JShrink\Minifier::minify($code); } else { if ($language == "html") { $html = new Tinyfier_HTML_Tool(); if ($minInline) { return $html->process($code, array("compress_all" => true)); } else { return $html->process($code, array("compress_all" => false)); } } } } } }