One of the main problems faced by those who work with JavaScript is how to keep the code safe and light when you move the code into the production phase or redistribution of code.
Even if client that run your code (Desktop Browser, Mobile Browser, Smart TV..) have different memory availability, different bandwidth and different performances, it is always a good idea to develop code tailored to the clients with fewer resources. It is a matter of fact that lightweight code runs faster.

In addition to keeping the code light there are times when it is necessary to obscure the code to protect user security during navigation. IMPORTANT: JavaScript is, by it’s very nature, not safe. This is because the code is downloaded and executed on the end device. We can, however, make reading the code a very complicated procedure.

Google suggests an endless list of tools, however, I can tell you by experience, they are almost always very hard to get running, not very useful, and there’s always the risk of breaking code integrity by renaming variables and/or functions, inc cases where code execution depends on specific names.

Today I’ll talk about a very powerful tool that even though relatively unknown performs its job properly, this tool is Microsoft Ajax Minifier.
Here you can find the documentation.

You can skip previuos link if you want to perform a test, you can run the same piece of code that I use to minimize the livebox.js code:

cat ../logic/*.js ../LiveBox.js | “C:/Program Files (x86)/Microsoft/Microsoft Ajax Minifier/AjaxMin.exe” -js -out LiveBoxMinified.js –clobber

JS Minified

Enjoy!

Safe JavaScript redistribution

Leave a Reply