HTTP headers | SourceMap

The HTTP SourceMap header is a response-type header used to map original source from the transformed source. For example, the Javascript resources are transformed to some other source from its original by the browsers at the time of execution. In the process of debugging, it is too difficult to debug a transformed source. On the other hand, the original source can be easily debugged. Hence, the SourceMap header is used to obtain the original source. SourceMap header enables the browser to reconstruct the original source from the transformed source and present it in the debugger. It links the generated code with the source code.

Syntax:

SourceMap: <url>

Directives: The HTTP SourceMap header accepts a single directive mentioned above and described below:



  • <url>: This directive represents the location of the SourceMap file for which the original file is to be obtained.

Example:

  • In this example, the URL mentioned points to the SourceMap file i.e, the transformed source whose reconstructed original source is to be obtained.
    SourceMap: /geeks/gfg/file.js.map
  • This example, you may not see because this X-SourceMap is deprecated, the URL mentioned points to the SourceMap file i.e, the transformed source whose reconstructed original source is to be obtained.
    X-SourceMap: /geeks/g4g/main.js.map

Supported Browsers: The browsers are compatible with the HTTP SourceMap Header are listed below:

  • Google Chrome
  • Firefox
  • Opera
  • Safari



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.