Skip to content Skip to sidebar Skip to footer

Is It Bad To Base62 Encode A Javascript File?

I just found Dean Edwards javascript packer here: http://dean.edwards.name/packer/ It has a couple of options, Base62 encode Shrink variables To test it I took the latest ve

Solution 1:

Base 62 is nothing but a positional notation. That is, it can be used to represent very long normal text by a very shorter version.

Using Base62 adds an extra step before the js can be put to use by clients. For jQuery kind of library this step may take an extra 100ms to 500ms of time on clients, depending on many factors.

Now we can compare the reduction in time to download the script to extra time taken to execute the script. It may reduce download time by 50ms but takes an extra 100ms to process it. Diminishing returns!!

Solution 2:

It does create more work on the client. The client has to run the code to decode the encoded script. This is pretty obvious if you enter just a little bit of code in the encoding block.

For example:

var a = 10;

Encodes as:

eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(newRegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0 1=2;',3,3,'var|a|10'.split('|'),0,{}))

Post a Comment for "Is It Bad To Base62 Encode A Javascript File?"