jQuery的jquery-1.10.2.min.map触发404(未找到)

本文翻译自:jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)

I'm seeing error messages about a file, min.map , being not found: 我看到未找到有关文件min.map错误消息:

GET jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found) GET jQuery的jquery-1.10.2.min.map触发404(未找到)


Screenshot 屏幕截图

在此处输入图片说明

Where is this coming from? 这是哪里来的?


#1楼

参考:https://stackoom.com/question/1F3el/jQuery的jquery-min-map触发-未找到


#2楼

If Chrome DevTools is reporting a 404 for a .map file (maybe jquery-1.10.2.min.map , jquery.min.map or jquery-2.0.3.min.map , but can happen with anything) first thing to know is this is only requested when using the DevTools. 如果Chrome DevTools报告.map文件的404错误(可能是jquery-1.10.2.min.mapjquery.min.mapjquery-2.0.3.min.map ,但可能发生任何事情),首先要了解的是仅在使用DevTools时才要求这样做。 Your users will not be hitting this 404. 您的用户不会点击此404。

Now you can fix this or disable the sourcemap functionality. 现在,您可以解决此问题或禁用源地图功能。

Fix: get the files 修复:获取文件

Next, it's an easy fix. 接下来,这很容易解决。 Head to http://jquery.com/download/ and click the Download the map file link for your version, and you'll want the uncompressed file downloaded as well. 转到http://jquery.com/download/ ,然后单击您所用版本的“ 下载地图文件”链接,您还需要下载未压缩的文件。

在此处输入图片说明

Having the map file in place allows you do debug your minified jQuery via the original sources, which will save a lot of time and frustration if you don't like dealing with variable names like a and c . 将地图文件放置在适当的位置允许您通过原始资源调试缩小的jQuery,如果您不喜欢处理变量名(如ac ,则可以节省大量时间和沮丧的时间。

扫描二维码关注公众号,回复: 10627861 查看本文章

More about sourcemaps here: An Introduction to JavaScript Source Maps 有关源映射的更多信息,请参见: JavaScript源映射简介。

Dodge: disable sourcemaps 道奇:禁用源地图

Instead of getting the files, you can alternatively disable JavaScript source maps completely for now, in your settings. 除了获取文件外,您还可以在设置中暂时完全禁用JavaScript源映射。 This is a fine choice if you never plan on debugging JavaScript on this page. 如果您从未打算在此页面上调试JavaScript,那么这是一个不错的选择。 Use the cog icon in the bottom right of the DevTools, to open settings, then: 使用DevTools右下方的cog图标打开设置,然后: 在此处输入图片说明


#3楼

As I understand the browser, Chrome at least, it doesn't disable the source mapping by default. 据我了解,至少Chrome是浏览器,默认情况下它不会禁用源映射。 That means your application's users will trigger this source-mapping request by default. 这意味着您的应用程序的用户将默认触发此源映射请求。

You can remove the source mapping by deleting the //@ sourceMappingURL=jquery.min.map from your JavaScript file. 您可以通过从JavaScript文件中删除//@ sourceMappingURL=jquery.min.map来删除源映射。


#4楼

You can remove the 404 by removing the line 您可以通过删除行来删除404

//@ sourceMappingURL=jquery-1.10.2.min.map

from the top part of your jQuery file. 从jQuery文件的顶部开始。

The top part of the jQuery file will look like this. jQuery文件的顶部将如下所示。

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery-1.10.2.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. 为生产而进行构建时,连同最小化和合并JavaScript文件,您将生成一个源映射,其中包含有关原始文件的信息。 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. 当在生成的JavaScript中查询特定的行号和列号时,可以在源映射中进行查找,以返回原始位置。 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. 开发人员工具(当前为WebKit夜间版本,Google Chrome或Firefox 23+)可以自动解析源地图,并使其看起来好像您正在运行未缩小和未合并的文件。 (Read more on this here ) (了解更多关于此这里


#5楼

The new versions of jQuery require this file http://code.jquery.com/jquery-1.10.2.min.map jQuery的新版本需要此文件http://code.jquery.com/jquery-1.10.2.min.map

The usability of this file is described here http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ http://www.html5rocks.com/zh-CN/tutorials/developertools/sourcemaps/上介绍了此文件的可用性

Update: 更新:

jQuery 1.11.0/2.1.0 jQuery 1.11.0 / 2.1.0

// sourceMappingURL comment is not included in the compressed file . // sourceMappingURL注释不包含在压缩文件中


#6楼

  1. Download the map file and the uncompressed version of jQuery. 下载地图文件和jQuery的未压缩版本。 Put them with the minified version: 将它们放到最小版本中: 的JavaScript

  2. Include minified version into your HTML: 在您的HTML中包含缩小的版本: 的HTML

  3. Check in Google Chrome: 签入Google Chrome: 谷歌浏览器

  4. Read Introduction to JavaScript Source Maps 阅读JavaScript源地图简介

  5. Get familiar with Debugging JavaScript 熟悉调试JavaScript

发布了0 篇原创文章 · 获赞 7 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/asdfgh0077/article/details/105297934