I pasted the following code in google closure for reducing the size,selected the option ‘advanced’.
for(var i =0;i<7;++i)
{
alert(6);
}
After compilation , i got
for(var a=0;7>a;++a)alert(6);
So what is the advantage of changing variable name to ‘a’ and changing the condition to 7>a instead of a<7….Is there any performance improvement .If so why?
Advanced mode picks the shortest names possible. It starts with ‘a’. The reordering is done to maximize gzip compression. Neither are helpful for a snippet like yours but these with other transformations can make a large difference to a more significant code base. Generally the compiler transformation are aimed at code size not performance but to be at least performance neutral.