jQuery Code Only Runs When Firebug is Open

Share this article


So you may be wondering why your jQuery Code is only running when firebug is open on your browser. Well, this could be because you have used console.log commands in your code and the jQuery code is failing because the console doesn’t exist.

To fix this simple put your console.log and firebug commands inside the following code:

if (window.console) {

Ensure no JavaScript errors are thrown for browsers without Firebug installed

if (!window.console || !console.firebug)
    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() {}

Turn it into a debug function sir?
function debug(text) {
	if ((typeof(Debug) !== 'undefined') && Debug.writeln) {
	if (window.console && window.console.log) {
	if (window.opera) {
	if (window.debugService) {

If console available, log the error

if (typeof(console) != 'undefined' && typeof(console.log) == 'function') {
	// If console available, log the error.
	console.log('Problem hiding the form', e);
Sam DeeringSam Deering
View Author

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form