如何压缩/缩小像这个文件的JavaScript

时间:2011-12-30 08:53:25

标签: javascript

我怎样才能将这样的Javascript文件变成这样的小文件?

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('K M;I(M)1S 2U("2a\'t 4k M 4K 2g 3l 4G 4H");(6(){6 r(f,e){I(!M.1R(f))1S 3m("3s 15 4R");K a=f.1w;f=M(f.1m,t(f)+(e||""));I(a)f.1w={1m:a.1m,19:a.19?a.19.1a(0):N};H f}6 t(f){H(f.1J?"g":"")+(f.4s?"i":"")+(f.4p?"m":"")+(f.4v?"x":"")+(f.3n?"y":"")}6 B(f,e,a,b){K c=u.L,d,h,g;v=R;5K{O(;c--;){g=u[c];I(a&g.3r&&(!g.2p||g.2p.W(b))){g.2q.12=e;I((h=g.2q.X(f))&&h.P===e){d={3k:g.2b.W(b,h,a),1C:h};1N}}}}5v(i){1S i}5q{v=11}H d}6 p(f,e,a){I(3b.Z.1i)H f.1i(e,a);O(a=a||0;a<f.L;a++)I(f[a]===e)H a;H-1}M=6(f,e){K a=[],b=M.1B,c=0,d,h;I(M.1R(f)){I(e!==1d)1S 3m("2a\'t 5r 5I 5F 5B 5C 15 5E 5p");H r(f)}I(v)1S 2U("2a\'t W 3l M 59 5m 5g 5x 5i");e=e||"";O(d={2N:11,19:[],2K:6(g){H e.1i(g)>-1},3d:6(g){e+=g}};c<f.L;)I(h=B(f,c,b,d)){a.U(h.3k);c+=h.1C[0].L||1}Y I(h=n.X.W(z[b],f.1a(c))){a.U(h[0]);c+=h[0].L}Y{h=f.3a(c);I(h==="[")b=M.2I;Y I(h==="]")b=M.1B;a.U(h);c++}a=15(a.1K(""),n.Q.W(e,w,""));a.1w={1m:f,19:d.2N?d.19:N};H a};M.3v="1.5.0";M.2I=1;M.1B=2;K C=/\\$(?:(\\d\\d?|[$&`\'])|{([$\\w]+)})/g,w=/[^5h]+|([\\s\\S])(?=[\\s\\S]*\\1)/g,A=/^(?:[?*+]|{\\d+(?:,\\d*)?})\\??/,v=11,u=[],n={X:15.Z.X,1A:15.Z.1A,1C:1r.Z.1C,Q:1r.Z.Q,1e:1r.Z.1e},x=n.X.W(/()??/,"")[1]===1d,D=6(){K f=/^/g;n.1A.W(f,"");H!f.12}(),y=6(){K f=/x/g;n.Q.W("x",f,"");H!f.12}(),E=15.Z.3n!==1d,z={};z[M.2I]=/^(?:\\\

我有一个脚本,只有在这样的情况下才能工作,如果我在浏览器中查看源代码,虽然我可以将其视为常规代码并对其进行编辑,但除非它采用该格式,否则给我错误。

我只需要知道如何打包它,我已经在网上尝试了缩小工具,甚至是JS UglifyJS,但是他们这样做而不是......

if(typeof SyntaxHighlighter=="undefined")var SyntaxHighlighter=function(){function b(a,b){return a.className.indexOf(b)!=-1}function c(a,c){b(a,c)||(a.className+=" "+c)}function d(a,b){a.className=a.className.replace(b,"")}function e(a){var b=[];for(var c=0;c<a.length;c++)b.push(a[c]);return b}function f(a){return a.split(/\r?\n/)}function g(a){var b="highlighter_";return a.indexOf(b)==0?a:b+a}function h(b){return a.vars.highlighters[g(b)]}function i(a){return document.getElementById(g(a))}function j(b){a.vars.highlighters[g(b.id)]=b}function k(a,b,c){if(a==null)return null;var d=c!=1?a.childNodes:[a.parentNode],e=

2 个答案:

答案 0 :(得分:3)

eval(function(p,a,c,k,e,d){…

这是packer by Dean Edwards的商标。编码为Base62使用缩小变量。

答案 1 :(得分:1)

使用此http://javascriptcompressor.com/

并启用base62编码以打包您的代码