美文网首页前端技巧我爱编程
ajaxmin(js,css压缩工具)

ajaxmin(js,css压缩工具)

作者: 恬雅过客 | 来源:发表于2016-02-05 20:37 被阅读175次

Microsoft Ajax Minifier使用:

使用方法一:

开始-->Microsoft Ajax Minifier-->Microsoft Ajax Minifier Command Prompt,弹窗命令窗口,输入相关命令即可。

使用方法二:

找到安装目录(C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier),找到AjaxMinCommandPrompt.bat,双击它就会弹窗命令窗口,输入相关命令即可。

(用ajaxmin或ajaxmin.exe都行,都是调安装目录下的AjaxMin.exe程序)

  1. 压缩并覆盖源文件
    ajaxmin inputfile.js
  2. 压缩到新文件(若文件已经存在会报错)
    ajaxmin inputfile.js -out outputfile.js
    ajaxmin.exe inputfile.js -out outputfile.js
  3. 用参数 -clobber 覆盖目标文件时不报错
    ajaxmin inputfile.js –out outputfile.js -clobber
    ajaxmin.exe inputfile.js –out outputfile.js -clobber
  4. 缺省状态下,本工具将重命名所有的本地变量和函数,若不想更改,可使用-rename:none参数
    ajaxmin -rename:none inputfile.js -out outputfile.js
    ajaxmin.exe -rename:none inputfile.js -out outputfile.js
  5. 偶尔在调试已经压缩过的js文件或则需要分析已有的压缩过的js文件时,可以使用这个工具进行还原,这样规范化以后由于格式整齐,就更好分析。
    ajaxmin -pretty demo.min.js -clobber -o demo.js
    ajaxmin.exe -pretty demo.min.js -clobber -o demo.js

压缩原理


  • 去掉不必要的空格
  • 去掉备注(忽略标注了"important"的备注)
  • 去除不必要的分号
  • Remove curly-braces around most single-statement blocks.
  • 重命名本地变量和函数
  • Determine best string delimiters (single- or double-quotes) based on which option will generate the fewer escaped characters within the string.
  • 合并多行连续的变量声明
  • 删除构造函数中的空参数
  • Remove unreferenced names for named function expressions.
  • 删除无引用的本地函数
  • 删除无法到达的代码

相关文章

  • ajaxmin(js,css压缩工具)

    Microsoft Ajax Minifier使用: 使用方法一: 开始-->Microsoft Ajax Min...

  • web面试笔试题摘取

    一、css js 压缩工具 JavaScript Minifier JSMIni JSCompress Minif...

  • netcore 网站优化

    css 文件引用放在head里面,js文件引用放在body底部,css js用压缩工具压缩成min.css 和mi...

  • js,css压缩工具

    网上搜过一些js,css压缩工具,也试用了好几款。有online的,有client的。一个28.3kb的css文件...

  • 移动端reset.css压缩版

    css文件压缩工具地址

  • 【前端入门单词】

    style 样式 type 类型 doctype 文档类型 css sprite 背景图压缩工具 charset ...

  • 60s倒计时

    JS实现 html js css vue实现 html js css

  • css加载会造成阻塞吗

    结论: css不会阻塞js的解析 css会阻塞js的渲染 css会阻塞js的执行 如果页面中同时存在css和js,...

  • js混淆

    js混淆工具--开源项目 Uglifyjs(开源) uglifyjs是一个开源的js 压缩工具,主要用于压缩,混淆...

  • 无缝轮播

    无缝细解过程 html css js 无缝轮播js切换动画 css代码 JS代码 循环无缝轮播 CSS js1.首...

网友评论

    本文标题:ajaxmin(js,css压缩工具)

    本文链接:https://www.haomeiwen.com/subject/jgtykttx.html