Demo address: www. atool. orgyui. php supports all functions and commands of YUICompressor, and supports online compression, obfuscation, and merging of JavascriptCss files to reduce the number of website network requests and connections. Multiple files can be compressed and merged. Note that the merged files belong to the same type, js or css, and cannot be mixed. YUI
Demo address: http://www.atool.org/yui.php supports all the functions and commands of YUICompressor, supports Javascript/Css online compression, obfuscation and merge files, thus reducing the number of web site requests and connections. Multiple files can be compressed and merged. Note that the merged files belong to the same type, js or css, and cannot be mixed. YUI
Demo address: http://www.atool.org/yui.php
Supports all functions and commands of YUI Compressor, and supports online compression, obfuscation, and merging of Javascript/Css files to reduce the number of website network requests and connections.
Multiple files can be compressed and merged. Note that the merged files belong to the same type, js or css, and cannot be mixed.
YUI Compressor
function compress() { // read the input foreach ($this->files as $file) { $this->string .= file_get_contents($file) or die("Cannot read from uploaded file"); } // create single file from all input $input_hash = sha1($this->string); $file = $this->TEMP_FILES_DIR . '/' . $input_hash . '.txt'; $fh = fopen($file, 'w') or die("Can't create new file"); fwrite($fh, $this->string); fclose($fh); // start with basic command $cmd = "java -Xmx32m -jar " . escapeshellarg($this->JAR_PATH) . ' ' . escapeshellarg($file) . " --charset UTF-8"; // set the file type $cmd .= " --type " . (strtolower($this->options['type']) == "css" ? "css" : "js"); // and add options as needed if ($this->options['linebreak'] && intval($this->options['linebreak']) > 0) { $cmd .= ' --line-break ' . intval($this->options['linebreak']); } if ($this->options['verbose']) { $cmd .= " -v"; } if ($this->options['nomunge']) {$cmd .= ' --nomunge';}if ($this->options['semi']) {$cmd .= ' --preserve-semi';}if ($this->options['nooptimize']) {$cmd .= ' --disable-optimizations';} // execute the command exec($cmd . ' 2>&1', $raw_output); // add line breaks to show errors in an intelligible manner $flattened_output = implode("\n", $raw_output); // clean up (remove temp file) unlink($file); // return compressed output return $flattened_output; }