ESC之ESC.wsf可以实现javascript的代码压缩附使用方法第2/5页

 更新时间:2007年05月07日 00:00:00   作者:  
可以对javascript的大小进行压缩。使javascript的加载速度变快。

Crunching, level by level   

Level 0 :: No compression 
No compression done. Basically a content transfer/append from input(s) to output. This level is mainly used for tracking down problems occuring to scripts after been shoved through the variable substitution engine.      

Level 1 :: Comment removal 
ESC removes empty lines (\r?\n)+, single and multi-line and single-line comments (//..., /* ... */) and trailing whitespace. [ \t]+\r?\n  

 
Level 2 :: Whitespace removal 
Any occurance of space and tabs (\s\t\r) are removed from the infile(s). This is the default compression-level if none is supplied.  

 
Level 3 :: Newline removal 
Newlines (\r?\n) are removed. ESC do not like sloppy written code and will at this level punish you for it by producing a very tight, human unreadable, uninpretable chunk o' chars :) So remember, *ALWAYS* terminate your statements with semi-colons (';'). If you come from a C/C++ bg you have probably been taught this the hard way by an evercroaking compiler. If not for getting your script thru ESC, so start doing it anyway for good ol' programming style.  

 
Level 4 :: Variable substitution 
(variable substitution mode, identical to options '-l 3 -$') Additionally to level 3, ESC will run your script(s) through the variable substitution engine. This will certainly break your scripts at the first try, but with a little fiddling around and once you understand how the substitution scheme works, this thing rule since it will save you another extra 5-20% bytewise depending on your coding style. Variable-names less than 3 chars are not affected. Before you try running ESC with variable substitution enabled, I advice you to carefully read the other sections in this manual about the pros and cons, thinking session-dependencies and the known caveats of variable crunching with ESC. Your specific situation in terms of namespaces, shared variables or the design/architecture of your scripts may make it difficult, even impossible to combine with this technique whereas you'll have to stick with level 3.  

相关文章

  • JavaScript前补零操作实例

    JavaScript前补零操作实例

    这篇文章主要介绍了JavaScript前补零操作的方法,以实例形式对比分析了javascript实现补零操作的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-03-03
  • JavaScript闭包详解

    JavaScript闭包详解

    这篇文章主要为大家介绍了JavaScript闭包,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助
    2021-11-11
  • 基于JSON数据格式详解

    基于JSON数据格式详解

    下面小编就为大家带来一篇基于JSON数据格式详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-08-08
  • js数据类型转换与流程控制操作实例分析

    js数据类型转换与流程控制操作实例分析

    这篇文章主要介绍了js数据类型转换与流程控制操作,结合实例形式分析了JavaScript数据类型转换与流程控制相关原理、操作技巧与使用注意事项,需要的朋友可以参考下
    2019-12-12
  • 带你领略Object.assign()方法的操作方式

    带你领略Object.assign()方法的操作方式

    这篇文章主要介绍了带你领略Object.assign()方法的操作方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-08-08
  • 原生js验证简洁注册登录页面

    原生js验证简洁注册登录页面

    这篇文章主要为大家详细介绍了原生js验证简洁美观注册登录页面的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-12-12
  • js实现5秒倒计时重新发送短信功能

    js实现5秒倒计时重新发送短信功能

    这篇文章主要为大家详细介绍了js实现5秒倒计时重新发送短信功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-02-02
  • 微信小程序下拉加载和上拉刷新两种实现方法详解

    微信小程序下拉加载和上拉刷新两种实现方法详解

    这篇文章主要介绍了微信小程序下拉加载和上拉刷新两种实现方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-09-09
  • JavaScript实现五子棋小游戏

    JavaScript实现五子棋小游戏

    这篇文章主要为大家详细介绍了JavaScript实现五子棋小游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2020-10-10
  • 使用JavaScript进行表单校验功能

    使用JavaScript进行表单校验功能

    最近在学习JavaScript,因此想到使用js实现表单校验。下面通过本文给大家分享使用javascript实现表单校验功能的步骤,需要的的朋友参考下吧
    2017-08-08

最新评论