Is Annotation in Javascript? If not, how to switch between debug/productive modes in declarative way

Posted by Michael Mao on Stack Overflow See other posts from Stack Overflow or by Michael Mao
Published on 2010-03-18T02:51:37Z Indexed on 2010/03/18 3:01 UTC
Read the original article Hit count: 406

Filed under:
|

Hi all:

This is but a curious question. I cannot find any useful links from Google so it might be better to ask the gurus here.

The point is: is there a way to make "annotation" in javascript source code so that all code snippets for testing purpose can be 'filtered out' when project is deployed from test field into the real environment?

I know in Java, C# or some other languages, you can assign an annotation just above the function name, such as :

// it is good to remove the annoying warning messages
@SuppressWarnings("unchecked")
public class Tester extends TestingPackage 
{
    ...
}

Basically I've got a lot of testing code that prints out something into FireBug console. I don't wanna manually "comment out" them because the guy that is going to maintain the code might not be aware of all the testing functions, so he/she might just miss one function and the whole thing can be brought down to its knees.

One other thing, we might use a minimizer to "shrink" the source code into "human unreadable" code and boost up performance (just like jQuery.min), so trying to match testing section out of the mess is not possible for plain human eyes in the future.

Any suggestion is much appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery