Skip to the content...

Welcome to the David Walsh Blog. I'm a MooTools, Dojo, jQuery, CSS, and PHP Web Developer located in Madison, Wisconsin, United States. Please contact me if I can make your experience on my website better.

How to Sniff & Disable Firebug

13 Responses »

If you're a hardcore Web Developer like me, you're probably well aware of the excellent Firefox plugin known as Firebug. Firebug's built in tools for monitoring and debugging CSS, HTML, and JavaScript/AJAX can improve development time efficiency exponentially.

As great as Firebug is, using Firebug does have its disadvantages while browsing websites that perform numerous AJAX requests. Firebug chokes on trying to analyze and display all of the information that it can make Firefox hang up. This, of course, is followed by [CONTROL] + [ALT] + [DELETE] and a restart of Firefox. Two such websites that warn users about this problem are Gmail and NetVibes.

If you fear that a website you are developing could cause problems for visitors with Firebug enabled, you have a few options for preventing problems.

Sniffing Firebug and Displaying A Message

The following JavaScript sniffs for Firebug. You could use this to display a "Please disable Firebug..." type of message.

if (window.console && window.console.firebug) {
	/* firebug found! */
}

Disable Firebug Functionality

The following JavaScript code doesn't disable Firebug but renders some problem functionality useless. The following snippet of code was taken from Yahoo! Media Player.

if (! ('console' in window) || !('firebug' in console)) {
    var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];
    window.console = {};
    for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
}

Discussion

  1. March 12, 2008 @ 10:10 am

    Excellent snippets, saves a lot of source code viewing and google searching. You can see that firebug does have quite an impact on the web.

    One thing that *I* think happened to my firefox, was that it can’t be opened right now. I’ve restarted my machine multiple times and I get the message “Firefox is already running.” I got the message a lot on linux machines and that usually just involved me deleting my profile folder in .mozilla , but I am not too sure where this folder exists in my windows box. The issue in the linux, was that I did not close the firefox window in another linux box when I logged off (all of the linuxes box where networked together using nfs so my data will be the same regardless of which box I logged into) I am willing to bet this is firebug related, since the last time I used it, firefox abruptly closed after opening like the 30th tab. /endrant

  2. March 14, 2008 @ 12:58 pm

    I’m not sure if that’s a Firebug issue but it happens to me quite a bit with fire fox. The fix for that is going into windows task manager, hit the processes tab and look for the file named “firefox.exe”, once found, highlight it and then click the end process button. Now start up firefox…should work again.

  3. johng
    March 15, 2008 @ 7:31 am

    interesting!

  4. melindrea
    September 24, 2008 @ 2:42 pm

    Is there any way to disable Firebug if the user has javascripts disabled?

    Thank you,
    Melindrea

  5. September 24, 2008 @ 2:43 pm

    @Melindrea: I don’t believe so.

  6. melindrea
    September 24, 2008 @ 2:52 pm

    Thanks anyways. =)

  7. mastr3s
    October 16, 2008 @ 2:58 am

    This really great script i’ve ever see can execute Firebug. I use firebug but i hate it when they see all activity on my web. Now i’m good

  8. krepa
    December 15, 2008 @ 1:29 pm

    I tried that solution to disabling firebug but doesnt excatly work right, would you have any idea how to disable the acutally console fully..

  9. February 7, 2009 @ 3:31 am

    It doesn’t work,
    I can detect whether firebug is installed or not, but i cant stop it.
    I need to hide the url’s i call with ajax, but in the firebug’s panel it is all open

  10. May 26, 2009 @ 3:50 pm

    @Jesus DeLaTorre try this command line:

    sudo killall -9 firefox

    and then restart your Firefox

  11. jr
    July 19, 2009 @ 11:25 am

    The sniffing code correctly detects Firebug, but the code that supposedly disables Firebug functionality runs only in the absence of Firebug. As I read it, that code is intended to prevent Firebug function calls from within the Yahoo! media player from throwing errors in browsers that don’t have Firebug installed.

    If you’re terribly concerned with people using Firebug’s console on your site, you could try the following to hinder them:

    if (window.console && window.console.firebug) {
    for (var x in console) {
    delete console[x];
    }
    }

    Keep in mind that this affects only the console of Firebug; all other features will likely work normally. Also, while Firebug is immensely popular, it is far from the only tool to execute user Javascript.

    Cheers =)

  12. sashi
    September 14, 2009 @ 2:21 am

    Hi, i would like to know, how i can disable firebug on a bebo application page. I have developed a bebo application, using php and bebo api. But the casual javascript code to disable firebug does not work there.
    Please, can any body tell me, how i can disable the javascript there, as the firebug is driving me mad, when users crack the game and cheat with the points.

  13. jason
    July 16, 2010 @ 4:47 pm

    Worked great if console was enabled, but we found that a user doesn’t have to have Console enabled to run Net enabled and that having the Net panel enabled causes js conflicts. Has anyone else found a way to detect if the other panels, such Net are enabled when Console is not?

Be Heard!

Share your thoughts with fellow developers of all skill levels! I want to hear from you!

Name*:
Email*:
Website:  
Wrap your code with <code> tags, f00!