Why am I getting “jquery.mobile-1.3.2.min.map file not found” message in Chrome

北慕城南 提交于 2019-12-21 03:09:29

问题


I'm using these three CDN files, as recommended on getting started in JQM documentation:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

I'm perplexed why I'm getting a 404 Not found status under the Network tab in Chrome. Seems to be looking jquery mobile min.map file. I don't see this in Firefox.

Any thoughts as to why it's looking for this file?


回答1:


Probably your Google Chrome DevTools has enabled the option "Enable source maps". Check your Settings menu, then General and Sources.

A source map file it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location. Developer tools (currently WebKit nightly builds, Google Chrome, or Firefox 23+) can parse the source map automatically and make it appear as though you're running unminified and uncombined files.

More information here.




回答2:


File not found : 404 will be shown only in browser developer tools. If developer tools are not opened the sourcemap file will not be accessed from browser

You can remove the 404 by removing the line

//@ sourceMappingURL=jquery-1.x.xmin.map

from the top part of your jQuery file.

The top part of the jQuery file will look like this.

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery-1.x.x.min.map
*/

Just change that to

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license */

Purpose of a source map

Basically it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location. Developer tools (currently WebKit nightly builds, Google Chrome, or Firefox 23+) can parse the source map automatically and make it appear as though you're running unminified and uncombined files. (Read more on this here)



来源:https://stackoverflow.com/questions/18381787/why-am-i-getting-jquery-mobile-1-3-2-min-map-file-not-found-message-in-chrome

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!