views:

27

answers:

0

In my javascript I have some bits of code specifically used for debugging which I don't want to include in the live site. Is there a way I can semi-comment these bits of code so that they run as javascript normally, but that yui compressor thinks they're comments and removes them?

For example

for(key in modules) {
  try { 
     MyApp[key].init(modules[key].params);
  } catch (e) {
     console.log("Module " + key + " threw an error");
     break;
  }
}

I would like to be able to comment out the console.log bit automatically when compressing to deploy to the live site. So maybe wrap the code in something like

   //yuiIgnore
         console.log("Module " + key + " threw an error");
   //endyuiIgnore