SourceMap header

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

The HTTP SourceMap response header provides the location of a source map for the resource.

The HTTP SourceMap header has precedence over a source annotation (sourceMappingURL=path-to-map.js.map), and if both are present, the header URL is used to resolve the source map file.

Header type Response header

Syntax

http
SourceMap: <url>
X-SourceMap: <url> (deprecated)

Directives

<url>

A relative (to the request URL) or absolute URL pointing to a source map file.

Examples

Linking to a source map using the SourceMap header

The following response contains an absolute path in the SourceMap header.

http
HTTP/1.1 200 OK
Content-Type: text/javascript
SourceMap: /path/to/file.js.map

<optimized-javascript>

Developer tools use the source map to reconstruct the original source from the optimized JavaScript returned in the response, allowing developers to debug the original code rather than the format that has been optimized for sending.

Specifications

Specification
Source map format specification
# sec-linking-http-header

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
SourceMap
Chrome – Full support
Chrome 18 (Release date: 2012-03-28)
prefix
prefix Implemented with the vendor prefix: X-
Chrome – Full support
Chrome 18 (Release date: 2012-03-28)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
prefix
prefix Implemented with the vendor prefix: X-
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
Firefox – Full support
Firefox 27 (Release date: 2014-02-04)
prefix
prefix Implemented with the vendor prefix: X-
Firefox – Full support
Firefox 55 (Release date: 2017-08-08)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
prefix
prefix Implemented with the vendor prefix: X-
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
Safari – Full support
Safari 6 (Release date: 2012-07-25)
prefix
prefix Implemented with the vendor prefix: X-
Safari – Full support
Safari 7 (Release date: 2013-10-22)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
prefix
prefix Implemented with the vendor prefix: X-
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
Firefox for Android – Full support
Firefox for Android 27 (Release date: 2014-02-04)
prefix
prefix Implemented with the vendor prefix: X-
Firefox for Android – Full support
Firefox for Android 55 (Release date: 2017-08-08)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
prefix
prefix Implemented with the vendor prefix: X-
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
prefix
prefix Implemented with the vendor prefix: X-
Safari on iOS – Full support
Safari on iOS 7 (Release date: 2013-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
prefix
prefix Implemented with the vendor prefix: X-
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
prefix
prefix Implemented with the vendor prefix: X-
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote
footnote Not supported for ECMAScript Modules (<script type="module">). See bug 40854862.
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
prefix
prefix Implemented with the vendor prefix: X-
WebView on iOS – Full support
WebView on iOS 7 (Release date: 2013-09-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also