导航:首页 > 编程语言 > uglifyjs使用

uglifyjs使用

发布时间:2024-04-19 07:52:31

『壹』 如何使用nodejs 的 uglifyjs 压缩js文件

[js压缩]uglifyjs source.js -mc -o target.min.js
以压缩angular.js为例,可以压缩局部变量名,去掉无用的局部变量,空白符等,压缩比例接近80%,效率不错
[user_00@ ~]$ uglifyjs angular.js -mc -o angular.min.js
WARN: Dropping unused function isBoolean [angular.js:416,9]
WARN: Dropping unused function makeMap [angular.js:446,9]
WARN: Dropping unused function size [angular.js:488,9]
WARN: Dropping unused function isLeafNode [angular.js:523,9]
WARN: Dropping unused function argument boundTranscludeFn [angular.js:4682,27]
WARN: Dropping unused function argument rootElement [angular.js:4681,16]
WARN: Dropping unused function argument nodeList [angular.js:4680,17]
WARN: Dropping unused function argument scope [angular.js:4679,22]
WARN: Dropping unused function nodesetLinkingFn [angular.js:4678,9]
WARN: Dropping unused function argument boundTranscludeFn [angular.js:4690,27]
WARN: Dropping unused function argument rootElement [angular.js:4689,16]
WARN: Dropping unused function argument node [angular.js:4688,13]
WARN: Dropping unused function argument scope [angular.js:4687,22]
WARN: Dropping unused function argument nodesetLinkingFn [angular.js:4686,25]
WARN: Dropping unused function directiveLinkingFn [angular.js:4685,9]
WARN: Dropping unused function stripHash [angular.js:5009,9]
WARN: Dropping unused variable NG_SWITCH [angular.js:13857,4]
WARN: Dropping unused variable fns [angular.js:1536,8]
WARN: Dropping unused variable events [angular.js:1536,13]
WARN: Dropping unused function wrongMode [angular.js:3879,13]
WARN: Dropping unused function argument cause [angular.js:4799,31]
WARN: Dropping unused function argument exception [angular.js:4799,20]
WARN: Dropping unused function argument args [angular.js:8165,28]
WARN: Dropping unused function argument args [angular.js:8231,33]
WARN: Dropping unused function argument names [angular.js:9018,32]
WARN: Dropping unused function argument name [angular.js:9030,40]
WARN: Dropping unused variable value [angular.js:9230,14]
WARN: Dropping unused function argument value [angular.js:12475,36]
[user_00@localhost ~]$ ls -lh angular.*
-rw-rw-r-- 1 user_00 user_00 479K Apr 5 01:53 angular.js
-rw-rw-r-- 1 user_00 user_00 79K May 4 16:09 angular.min.js

『贰』 npm安装完uglifyjs怎么对js代码进行混淆

如果你是全局安装的,可以直接在需要混淆文件的目录下,

按住shift键右击鼠标选择在此处打开命令窗口如图

新建test.js开始测试
varUglifyJS=require('uglify-js');

//代码压缩
varresult=UglifyJS.minify("varb=function(){};",{fromString:true});
console.log(" ===========================");
console.log(result);

//文件压缩
result=UglifyJS.minify(["demo.js"]);
console.log(" ===========================");
console.log(result.code);

//多文件压缩,指定sourcemap和网站来源
result=UglifyJS.minify(["main.js","demo.js"],{
outSourceMap:"out.js.map",
sourceRoot:"http://onbook.me",
mangle:true
});
console.log(" ===========================");
console.log(result.code);
console.log(result.map);

http://blog.fens.me/nodejs-uglifyjs2-js/

阅读全文

与uglifyjs使用相关的资料

热点内容
java引用传递和值传递 浏览:109
oracle下载安装教程 浏览:854
php筛选数据库 浏览:830
怎么用手机看wlan密码 浏览:745
奥维地图导入的文件在哪里 浏览:364
sdltrados2014教程 浏览:43
培训制度文件在哪里找 浏览:601
勒索病毒防疫工具 浏览:861
win10c不能打开 浏览:375
xfplay影音先锋苹果版 浏览:597
两个文件打开两个word 浏览:921
苹果6s桌面图标轻微抖动 浏览:326
如何删除手机中看不见的临时文件 浏览:469
安卓412原生锁屏apk 浏览:464
书加加缓存文件在哪里 浏览:635
dock是word文件吗 浏览:267
社保公司新办去哪个网站下载资料 浏览:640
三维标注数据怎么填写 浏览:765
数据线断在哪里取出来 浏览:522
word最好的文件 浏览:345

友情链接