脚本分析、压缩、混淆工具 JSA新版本发布,压缩效率提高大约10%

JSA 1.0 Alpha发布,压缩效率提高大约10%

最新更新(2007-05-23 IE5 bug) 感谢 PHPRPC 作者 andot  的bug报告:
下载地址:
http://sourceforge.net/project/showfiles.php?group_id=175776

压缩算法改进:

实现了自己的文本压缩算法
  • 提高了压缩比率以及解压效率。
优化了语法压缩
  • 合并连续var申明,
  • 删除了多余var申明,
  • 删除了多余大括弧({、}),
  • 删除了多余分号(;)。

UI改进:

  • 自动编码识别
  • 支持文件拖放
  • 支持JAVA1.4.2+ 当jar打开方式为java时,可双击运行,但,若JAR打开方式被修改(如winrar),请使用如下方式:
    CMD>java -jar xx.jar
  • 格式化
    注释只能在各语句之间,插在语句中间的注释有可能丢失,在格式化的时候,算bug吧。
  • 压缩参数设置
    操作->设置:
    执行语法压缩:将替换局部变量,删除冗余语法。
    执行文本压缩:将脚本文本分词、替换压缩。执行时可通过eval( 解压函数() )方式还原。
    兼容IE5、NS3:老版本的浏览器对正则表达式支持优先,是否需要兼容他们(需要采用稍微复杂一点的解压函数)。
    执行文本压缩的条件设置:设置何时采用文本压缩,有两项,比率要求和大小要求;因为eval是需要额外开销的,所以,只有当文本压缩的比率小于指定值且文件大小大于指定值时才采用文本压缩。

ANT Task

  • 默认编码 :取JRE的默认编码,可能随机器不同而改变,所以,推荐手动指定器编码方式(eg:charset="utf-8"/charset="GBK")
  • jsicompile 任务:编译JSI (压缩,预装载编译,定制启动文件)
  • jscompress 压缩脚本

ANT Task 示例

    jsicompiler 示例(处理JSI及其集成的第三方脚本)

    xml 代码
     
    1. <target name="compress" depends="init">  
    2.   <jsicompiler destDir="ant/temp/script2" charset="utf-8" rebuildboot="true">  
    3.     <fileset dir="web/scripts">  
    4.       <include name="*/**/*.js" />  
    5.       <include name="*.js" />  
    6.       <exclude name="preload/**" />  
    7.     </fileset>  
    8.     <preloadgroup path="code-decorator.js">  
    9.       <fileset dir="web/scripts">  
    10.         <include name='js/io/__$package.js' />  
    11.         <include name='js/io/request.js' />  
    12.         <include name='js/io/writer.js' />  
    13.         <include name='js/xml/__$package.js' />  
    14.         <include name='js/xml/template.js' />  
    15.         <include name='js/xml/tag.js' />  
    16.         <include name='js/util/__$package.js' />  
    17.         <include name='js/util/collections.js' />  
    18.         <include name='org/xidea/syntax/__$package.js' />  
    19.         <include name='org/xidea/syntax/syntax-parser.js' />  
    20.         <include name='org/xidea/decorator/__$package.js' />  
    21.         <include name='org/xidea/decorator/code.js' />  
    22.       </fileset>  
    23.     </preloadgroup>  
    24.   </jsicompiler>  
    25. </target>  

    jscompress 示例(压缩普通脚本)

    xml 代码
     
    1. <target name="test-compress">  
    2.   <jscompress destDir="ant/temp/script2" charset="utf-8">  
    3.     <fileset dir="web/scripts">  
    4.       <include name="js/**/*.js" />  
    5.       <include name="*.js" />  
    6.     </fileset>  
    7.   </jscompress>  
    8. </target>  

你可能感兴趣的:(JavaScript,ant,脚本,dojo,JSI)