Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

Message

Warning: SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead

Warning: SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead

Error type

A warning that a SyntaxError occurred. JavaScript execution won't be halted.

What went wrong?

There is a deprecated source map syntax in a JavaScript source.

JavaScript sources are often combined and minified to make delivering them from the server more efficient. With source maps, the debugger can map the code being executed to the original source files.

The source map specification changed the syntax due to a conflict with IE whenever it was found in the page after //@cc_on was interpreted to turn on conditional compilation in the IE JScript engine. The conditional compilation comment in IE is a little known feature, but it broke source maps with jQuery and other libraries.

Examples

Deprecated syntax

Syntax with the "@" sign is deprecated.

//@ sourceMappingURL=https://example.com/path/to/your/sourcemap.map

Standard syntax

Use the "#" sign instead.

//# sourceMappingURL=https://example.com/path/to/your/sourcemap.map

Or, alternatively, you can set a header to your JavaScript file to avoid having a comment at all:

X-SourceMap: /path/to/file.js.map

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
New syntax (Yes) 24 (24) ? (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
New syntax ? ? 24.0 (24) ? ? ?

See also

文件標籤與貢獻者

 此頁面的貢獻者: fscholz
 最近更新: fscholz,