ESC Introduction
ESC is an ECMAScript pre-processor written in JScript, enabling an unlimited number of external scripts to be compressed/crunched into supertight, bandwidth-optimized packages. Featuring several compression-techniques such as comment removal, whitespace stripping, newline stripping and variable substitution ESC can reduce the overall size of your code with up to ~45%. Single, multiple scripts and even directories with scripts can be merged together at the compression level you decide. The processed output can later be appended or written to a file, or piped to another application for further processing via STDOUT.
ESC do NOT support crunching of inline scripts. So any attempt passing HTML, ASP, JSP, PHP or other equivalent documents to ESC is done at your own risk.
ESC supports four levels of compression, where a higher level equals higher compression. Beware though that levels >2 requires your code to be syntaxically perfect or ESC will punish you by producing a broken and useless output.
The compression ratio should hit around 25% using the default compression level on a vanilla looking script, but results as high as ~45% can be achieved depending on the script's design / your style of writing code.
ESC's compression engine is intelligent in the meaning that it has language syntax, statement and keyword awareness and it *knows* about native objects and members provided by the most common scripting hosts. This knowledgebase can easily be extended by pluggin in userdefined maps with additional information to further gain control of the crunching procedure. During processing following things are taken into account :
String and RegExpression read-ahead
Jscript Conditional compilation statements and variables
ECMA-262 Core language definitions (ECMAScript)
Intermediate DOM's (level 0) and DOM level 1
MS Jscript specific objects/methods
Netscape/Mozilla/Opera specific objects/methods/properties
MS WSH (Windows Scripting Host) 1+ native objects
压缩级别分为5种,从0到4
Level 0 :: No compression
Level 1 :: Comment removal
Level 2 :: Whitespace removal
Level 3 :: Newline removal
Level 4 :: Variable substitution
在WINDOWS命令行下执行
cscript ESC.wsf -ow menu2.js menu.js将会把menu.js按照js压缩级别2来压缩(默认js压缩级别为2)为menu2.js
cscript ESC.wsf -l 3 -ow menu3.js menu.js将会把menu.js按照js压缩级别3来压缩为menu3.js
需要注意的是,js压缩级别4会把变量名修改,如果你的js中用到了全局变量或者类的话,就不能使用该压缩级别了,否则其它使用你的js的文件可能会无法正常运行。
试了一下,把yui的menu.js压缩了一下,对应的级别和压缩率分别如下:
js压缩级别1:压缩率44.41%
js压缩级别2:压缩率62.82%
js压缩级别1:压缩率64.93%
原来130多K的js文件压缩后也就40多K,看来还是挺有用处的。
以上是引用原作者的话
##################################################################
如何批量压缩JAVASCRIPT?
!!!!使用前请先到设置参数段设置一下参数!!!!
用法:在WINDOWS下,将想压缩的JAVASCRIPT脚本拖放至此RUN.BAT上
之后将会进行一次性批量压缩,压缩后的脚本为原脚本路径下/C_原文件名
仅仅是为了让大家更方便的利用ESC.wsf压缩JAVASCRIPT,所以请大家保护原作者的权益。
欢迎大家使用此脚本,但请不要更改作者与出处
注:此脚本调用ESC.wsf压缩核心,用于批量压缩JAVASCRIPT脚本
AUTHOR:LIMING [leession@live.cn]
leession
- 粉丝: 10
- 资源: 2
最新资源
- C语言中使用OpenGL和SDL实现3D动态圣诞树效果
- 保险费用数据集.zip
- python圣诞树代码动态3d
- Anaconda Python 数据处理与分析工具的安装与配置教程
- C语言编程实现控制台打印2D圣诞树
- 动态直方图均衡化技术在图像对比度增强中的应用研究-论文复现-含代码详细解释
- 电脑视觉检测机项目设备3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- DataOptionError解决办法.md
- 使用HTML和CSS创建静态圣诞树的代码实例
- NSConditionLockException如何解决.md
- KeyError.md
- 大宗商品价格数据集.zip
- 全球互联网使用数据集,互联网使用影响因素数据集,提供了各国互联网使用的全面概览
- ConcurrentModificationException(解决方案).md
- ReferenceError.md
- python通过overpass获取城市所有建筑物经纬度
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈