Javascript Obfuscator
The code of the JavaScript apps, like the rest of the web page content, is accessible and viewable by any user. Many companies have developed complicated programs whose source code is open to every user since the introduction of AJAX-based applications.
JS Obfuscator
Obfuscators utilize a variety of approaches to make the source code of an application nearly hard to comprehend. Maintaining the application's behavior, they manage to dirty and make the code so tough that access to that code is not a major issue.
The Js obfuscating tool provides an example of the result of obfuscating certain JavaScript code. This is the original code before obfuscating it:
//------------------------------------------------ ------
// Calculate salary for each employee in "aEmployees".
// "aEmployees" is an array of "Employee" objects.
//------------------------------------------------ ------
function CalculateSalary ( aEmployees )
{
var nEmpIndex = 0 ;
while (nEmpIndex < aEmployees.length)
{ var oEmployee = aEmployees[nEmpIndex];
oEmployee.fSalary = CalculateBaseSalary(oEmployee.nType,
oEmployee.nWorkingHours); if (oEmployee.bBonusAllowed == true )
{
oEmployee.fBonus = CalculateBonusSalary(oEmployee.nType,
oEmployee.nWorkingHours,
oEmployee.fSalary);
} else
{
oEmployee.fBonus = 0 ;
}
oEmployee.sSalaryColor = GetSalaryColor(oEmployee.fSalary +
oEmployee.fBonus);
nEmpIndex++;
}
}
After passing the above code through the obfuscator the result is:
function CalculateSalary(aEmployees) {
var nEmpIndex = 0;
while (nEmpIndex < aEmployees.length) {
var oEmployee = aEmployees[nEmpIndex];
oEmployee.fSalary = CalculateBaseSalary(oEmployee.nType, oEmployee.nWorkingHours);
if (oEmployee.bBonusAllowed == true) {
oEmployee.fBonus = CalculateBonusSalary(oEmployee.nType, oEmployee.nWorkingHours, oEmployee.fSalary)
} else {
oEmployee.fBonus = 0
}
oEmployee.sSalaryColor = GetSalaryColor(oEmployee.fSalary + oEmployee.fBonus);
nEmpIndex++
}
}
Javascript Obfuscation Techniques
It is nearly hard to read the computer code by replacing all variable and function names with single letter names. This form of obfuscator is also occasionally used to reduce the size of the source code.
In addition to commercial apps intended expressly to obfuscate JavaScript code, tools that reduce script size can also be employed. Programs that reduce the size of scripts obscure their code by eliminating comments and shortening the names of all variables.
This tool is free, may be used through the web, and delivers outstanding code compression. You may also read this article about javascript deobfuscator or use this tool to deobfuscate javascript