Google has just released their JavaScript development toolbox which itself is not supported for use with Microsoft Dynamics CRM, however it does include a component called the Closure Inspector which will optimize, compress, and debug JavaScript code. The compression removes all of the unnecessart whitespace, so gone are the days of painfully trying to remove all of the whitespace so that the Jscript will work within the ISV.config file.
For example, I took a function from one of our CRM forms and compiled it with simple optimization in the Closure Compiler and here were the results:
Original
function billable() {
if (crmForm.all.sgs_billablehours.disabled == false) {
var minutes = prompt(’How many minutes?’, ‘0′);
var fullhours = minutes / 60;
fullhours = fullhours - fullhours % 1;
var remainder = (minutes % 60) / 60;
remainder = Math.ceil(10 * remainder) / 10;
crmForm.all.sgs_billablehours.DataValue = fullhours + remainder;
}
}
Compiled Code
function billable(){if(crmForm.all.sgs_billablehours.disabled==false){var a=prompt(”How many minutes?”,”0″),b=a/60;b-=b%1;a=a%60/60;a=Math.ceil(10*a)/10;crmForm.all.sgs_billablehours.DataValue=b+a}};
Original Size: 466 bytes (241 bytes gzipped)
Compiled Size: 262 bytes (189 bytes gzipped)
In conclusion, with CRM Jscipts usually being pretty small, the compression is probably not going to optimize performance much (unless you are on dialup, it takes a fraction of a second to download either 8KB or 16KB), however I do think that the debugging and whitespace removing features will come in very handy for me in the future. If you take advantage of the optimization, you will want to make sure that you save a copy of the original code since your comments will be removed and variable names will be changed.
Here is the link to the web based version of the Closure Compiler.
http://closure-compiler.appspot.com/home
For more information, check out the Ars Technica article where I discovered it:
http://arstechnica.com/open-source/news/2009/11/google-opens-up-its-javascript-development-toolbox-to-all.ars