JavaScript for Developers

 < Day Day Up > 

Some tools and preferences are very helpful to developers. One such tool is the JavaScript console, which is installed with JavaScript. A number of JavaScript-related preferences (some of which exist in about:config and some of which must be added) improve the usability of JavaScript debugging tools.

JavaScript Console

The JavaScript Console is a window (separate from Firefox's browser window) that displays error messages generated in JavaScript code. In Figure 14.5, you can see that the JavaScript Console started after opening Firefox and showed several errors in JavaScript code while running and a final error at shutdown.

Figure 14.5. The JavaScript Console is showing three errors and one information message.

The Venkman Extension

The Venkman extension is a powerful JavaScript debugger. Programmers familiar with systems such as Microsoft Visual Basic 6, Visual C/C++, and other programming development tools will be familiar with Venkman. The Venkman extension does the following:

  • Enables you to continue from the current point, perform single-step execution, step over a subfunction call, or step out of a subfunction call.

  • Profiles code, showing which parts seem to be consuming the most time. This gives information about which parts of the script should be optimized if possible.

  • Saves and restores settings such as breakpoints and variable watches. Venkman enables you to automatically save settings upon exit.

  • Opens both a web page and files. Most are displayed in tabs in the source code window, allowing you to easily navigate between each.

Venkman is the most powerful JavaScript development tool. It works well with other JavaScript tools and preferences (our next section).


Venkman is version specific. A certain version must be used with Firefox (and others must be used with Mozilla Suite). Be sure to use the correct version; otherwise, Venkman will not perform properly, if at all.

Debugging Preferences

When developing JavaScript, several preferences should be set to maximize the JavaScript Console's effectiveness:

  • browser.dom.window.dump.enabled = true This causes Firefox to enable the dump() statement, which prints to the standard console. You must start Firefox with the --console parameter.

  • javascript.options.showInConsole = true This tells Firefox to log chrome file errors to the JavaScript Console.

  • javascript.options.strict = true With the strict preference, this tightens the limits on error collection. This increases the number of logged warnings; you will see warnings in your code as well as in other code.

  • nglayout.debug.disable_xul_cache = true This tells Firefox to disable the XUL cache. If the XUL is cached, Firefox must be restarted for any changes to be effective.

Firefox Command-line Options

Firefox supports a number of command-line options. These are sometimes referred to as command-line parameters either terminology is acceptable. These options are documented at This page references Mozilla Suite, not Firefox, but most options listed there work with Firefox.

     < Day Day Up > 

    Firefox and Thunderbird. Beyond Browsing and Email
    Firefox and Thunderbird Garage
    ISBN: 0131870041
    EAN: 2147483647
    Year: 2003
    Pages: 245

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: