yep, use typeof: (function($){ // block scope
$.fn.log = function(msg){ if ( typeof window.console !== 'undefined' && typeof console.firebug !== 'undefined'){ msg = msg || ''; if(msg !== '') msg += ': '; console.log("%s%o", msg, this); } return this; }; })(jQuery);