YUICompressor online compression (Javascript/Css)

Source: Internet
Author: User
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;    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.