aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes questions about  console.info() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "questions about  console.info() " Watch "questions about  console.info() " New topic
Author

questions about console.info()

Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
I am using "console.info()" together with firefox firebug to debug js code,

i have following question:

can i leave all these console debugging code in the js file, and if my client is using IE, what will happen? is that going to produce any unhappy outcomes?

in other words, Is "console.info()" for firefox/firebug only, or it is a js built in function?


** SCJP 5.0 84% **
** SCWCD 1.5 76% **
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

The console methods are supported by a wide range of browsers, but will cause problems if the browser does not support then or if debugging is turned off. Besides, do your customers really want to see your debugging messages on their consoles?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
Bear Bibeault wrote:The console methods are supported by a wide range of browsers, but will cause problems if the browser does not support then or if debugging is turned off. Besides, do your customers really want to see your debugging messages on their consoles?



hi bear,

I dont know whether my client likes it or not.

my question is, how do you handle all these console debugging codes? we need to remove it one by one when the code is committed?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61428
    
  67

Personally, I remove them before a build.

Another tactic I've seen is to create your own wrapper method that does nothing if the symbol console is undefined, and performs logging if it is.
Chrix Wu
Ranch Hand

Joined: Nov 15, 2009
Posts: 121
Bear Bibeault wrote:Personally, I remove them before a build.

Another tactic I've seen is to create your own wrapper method that does nothing if the symbol console is undefined, and performs logging if it is.


thanks for your suggestion!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Better to remove them, nothing like leaving code in your application that does nothing. Milliseconds add up.

Eric
 
jQuery in Action, 2nd edition
 
subject: questions about console.info()