MDN will be in maintenance mode on Thursday September 21st, starting at 10 AM Pacific / 5 PM UTC, for about 1 hour.

This page describes the JavaScript Debugger as it appears in Firefox 52 and above. To see what it's like in earlier versions of Firefox, see Debugger (before Firefox 52).

If you're using Firefox 52 or later and need to switch back to the old Debugger, you can do so by visiting about:config and setting the "devtools.debugger.new-debugger-frontend" preference to false.

The JavaScript sources executed by the browser are often transformed in some way from the original sources created by a developer. For example:

  • sources are often combined and minified to make delivering them from the server more efficient.
  • JavaScript running in a page is often machine-generated, as when compiled from a language like CoffeeScript or TypeScript.

In these situations, it's much easier to debug the original source, rather than the source in the transformed state that the browser has downloaded. A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

To enable the debugger to work with a source map, you must:

  • generate the source map
  • include a comment in the transformed file, that points to the source map. The comment's syntax is like this:
//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map

In the video above we load https://mdn.github.io/devtools-examples/sourcemaps-in-console/index.html. This page loads a source called "main.js" that was originally written in CoffeeScript and compiled to JavaScript. The compiled source contains a comment like this, that points to a source map:

//# sourceMappingURL=main.js.map

In the Debugger's source list pane, the original CoffeeScript source now appears as "main.coffee", and we can debug it just like any other source.

Finally, depending on your browser version you might have to enable this feature inside the about:config section.

  1. To do this please open the browser and type in: about:config.
    How to open about:config inside firefox.
  2. Accept the warranty.
    Accept about:config warranty.
  3. Search for devtools.source-map.locations.enabled and set it to true.
    Change the sourcemap boolean value for devtools.

Document Tags and Contributors

 Contributors to this page: ra4ul, Daniel-KM, gabrielmicko, akikochuchu, wbamberg, jnachtigall
 Last updated by: ra4ul,