yuicompressor java_yuicompressor

yuicompressor java_yuicompressorYUICompressor-TheYahoo!JavaScriptandCSSCompressorTheYUICompressorisaJavaScriptcompressorwhich,inadditiontoremovingcommentsandwhite-spaces,obfuscateslocalvariablesusingthesma…

大家好,又见面了,我是你们的朋友全栈君。

YUI Compressor – The Yahoo! JavaScript and CSS Compressor

The YUI Compressor is a JavaScript compressor which, in addition to removing

comments and white-spaces, obfuscates local variables using the smallest

possible variable name. This obfuscation is safe, even when using constructs

such as ‘eval’ or ‘with’ (although the compression is not optimal in those

cases) Compared to jsmin, the average savings is around 20%.

The YUI Compressor is also able to safely compress CSS files. The decision

on which compressor is being used is made on the file extension (js or css)

Building

ant

Testing

./tests/suite.sh

Node.js Package

You can require compressor in a Node.js package and compress files and strings in async.

It still uses Java under the hood

npm i yuicompressor

var compressor = require(‘yuicompressor’);

compressor.compress(‘/path/to/file or String of JS’, {

//Compressor Options:

charset: ‘utf8’,

type: ‘js’,

nomunge: true,

‘line-break’: 80

}, function(err, data, extra) {

//err If compressor encounters an error, it’s stderr will be here

//data The compressed string, you write it out where you want it

//extra The stderr (warnings are printed here in case you want to echo them

});

Options:

charset // defaults to ‘utf8’

type // defaults to ‘js’

line-break

nomunge

preserve-semi

disable-optimizations

TODO

Better Docs

Help Pages

Build Status

yuicompressor.svg?branch=master

Global Options

-h, –help

Prints help on how to use the YUI Compressor

–line-break

Some source control tools don’t like files containing lines longer than,

say 8000 characters. The linebreak option is used in that case to split

long lines after a specific column. It can also be used to make the code

more readable, easier to debug (especially with the MS Script Debugger)

Specify 0 to get a line break after each semi-colon in JavaScript, and

after each rule in CSS.

–type js|css

The type of compressor (JavaScript or CSS) is chosen based on the

extension of the input file name (.js or .css) This option is required

if no input file has been specified. Otherwise, this option is only

required if the input file extension is neither ‘js’ nor ‘css’.

–charset character-set

If a supported character set is specified, the YUI Compressor will use it

to read the input file. Otherwise, it will assume that the platform’s

default character set is being used. The output file is encoded using

the same character set.

-o outfile

Place output in file outfile. If not specified, the YUI Compressor will

default to the standard output, which you can redirect to a file.

Supports a filter syntax for expressing the output pattern when there are

multiple input files. ex:

java -jar yuicompressor.jar -o ‘.css$:-min.css’ *.css

… will minify all .css files and save them as -min.css

-v, –verbose

Display informational messages and warnings.

JavaScript Only Options

–nomunge

Minify only. Do not obfuscate local symbols.

–preserve-semi

Preserve unnecessary semicolons (such as right before a ‘}’) This option

is useful when compressed code has to be run through JSLint (which is the

case of YUI for example)

–disable-optimizations

Disable all the built-in micro optimizations.

Notes

If no input file is specified, it defaults to stdin.

Supports wildcards for specifying multiple input files.

The YUI Compressor requires Java version >= 1.5.

It is possible to prevent a local variable, nested function or function

argument from being obfuscated by using “hints”. A hint is a string that

is located at the very beginning of a function body like so:

function fn (arg1, arg2, arg3) {

“arg2:nomunge, localVar:nomunge, nestedFn:nomunge”;

var localVar;

function nestedFn () {

….

}

}

The hint itself disappears from the compressed file.

C-style comments starting with /*! are preserved. This is useful with

comments containing copyright/license information. As of 2.4.8, the ‘!’

is no longer dropped by YUICompressor. For example:

/*!

* TERMS OF USE – EASING EQUATIONS

* Open source under the BSD License.

* Copyright 2001 Robert Penner All rights reserved.

*/

remains in the output, untouched by YUICompressor.

Modified Rhino Files

YUI Compressor uses a modified version of the Rhino library

(http://www.mozilla.org/rhino/) The changes were made to support

JScript conditional comments, preserved comments, unescaped slash

characters in regular expressions, and to allow for the optimization

of escaped quotes in string literals.

Copyright And License

Copyright (c) 2013 Yahoo! Inc. All rights reserved.

The copyrights embodied in the content of this file are licensed

by Yahoo! Inc. under the BSD (revised) open source license.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/161234.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java/JDK下载安装与环境配置(Windows 10 超详细的图文版教程 )「建议收藏」

    前言:对于很多初学者来说,我想可能很多人都会遇到的一个问题就是Java环境变量的配置问题。自己明明就是按照度娘上的教程去一步步配置的,但还是会有很多的人出现配置不成功的问题。所以今天在这里分享一下windows10系统下安装Java的教程,希望对Java初学者能有所帮助。一.Java的下载与安装作为初学者,要想学习Java语言,第一个条件就是要让电脑上具备有Java环境,那么怎么让电…

    2022年4月14日
    56
  • 主流大数据存储解决方案评析

    主流大数据存储解决方案评析EMC Isilon:横向扩展 性能突出大数据存储不是一类单独的产品,它有很多实现方式。EMC Isilon存储事业部总经理杨兰江概括说,大数据存储应该具有以下一些特性:海量数据存储能力,可轻松管理PB级乃至数十PB的存储容量;具有全局命名空间,所有应用可以看到统一的文件系统视图;支持标准接口,应用无需修改可直接运行,并提供API接口进行面向对象的管理;读写性能优异,聚合带宽高达数GB乃至数十GB…

    2022年6月2日
    45
  • RabbitMQ原理分析

    RabbitMQ原理分析RabbitMQ 简介基于 AMQP 协议实现 主要作用是解耦 冗余 扩展性 增大消息入队和处理的频率变得很容易 平滑峰值 可恢复性 送达保证 ACK 机制消费者消费消息后必须返回相应的 ACK 顺序保证等 文章当中使用的 RabbitMQ 的版本是 RabbitMQ3 6 6 关键概念 Exchange 交换机启动 RabbitMQ 相关的服务 会默认创建一个不可以删除的 Excha

    2025年6月8日
    1
  • VMware如何彻底卸载干净[通俗易懂]

    如何彻底卸载VMware虚拟机禁用VM虚拟机服务首先,需要停止虚拟机VMware相关服务。按下快捷键WIN+R,打开windows运行对话框,输入【services.msc】,点击确定。在服务管理中,找到VM开头的所有服务类别。将所有VM开头的服务禁用掉关闭VMware虚拟机进程按下Ctrl+Alt+Delete,打开任务管理器,找到所有VM开头的进程,全部结束进…

    2022年4月5日
    914
  • mt4服务器地址大全_mt4无法连接服务器

    mt4服务器地址大全_mt4无法连接服务器MT4服务器地址在哪个文件内容精选换一换VPC为弹性云服务器构建隔离的、用户自主配置和管理的虚拟网络环境,提升用户云中资源的安全性,简化用户的网络部署。使用弹性文件服务时,文件系统和云服务器归属于同一VPC下才能文件共享。VPC可以通过网络ACL进行访问控制。网络ACL是对一个或多个子网的访问控制策略系统,根据与子网关联的入站/出站规则,判断数据包是否被允许流入/流出关联子网。环境搭建完成后,若…

    2022年8月15日
    7
  • 什么是SOA架构?为什么使用SOA架构?

    什么是SOA架构?为什么使用SOA架构?SOA架构简介面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,通过这些服务之间定义良好的接口和契约联系起来。接口是采用中立的方式进行定义的,它应该独立于实现服务的硬件平台、操作系统和编程语言。这使得构建在各种这样的系统中的服务可以以一种统一和通用的方式进行交互**SOA具有以下五个特征**1.可重用;2.松耦合;3.明确定义的接口;…

    2022年6月24日
    29

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号