jQuery 缺少 .map 资源?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18499930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing .map resource?
提问by user2066880
I've recently started having this problem with all my projects. When my index page loads which contains a reference to the jquery source file, my console logs this error: GET http://localhost:3000/js/lib/jquery-1.10.2.min.map 500 (Internal Server Error)
.
我最近开始在我的所有项目中遇到这个问题。当我的索引页加载包含对 jquery 源文件的引用时,我的控制台会记录此错误:GET http://localhost:3000/js/lib/jquery-1.10.2.min.map 500 (Internal Server Error)
.
This doesn't affect my application at all, but it's really annoying to see whenever I open up the console. Does anyone know where this is coming from?
这根本不会影响我的应用程序,但是每当我打开控制台时看到它真的很烦人。有谁知道这是从哪里来的?
Edit: Note that I'm not explicitly referencing the .map file, I am just pointing to <script src="js/lib/jquery-1.10.2.min.js"></script>
编辑:请注意,我没有明确引用 .map 文件,我只是指向 <script src="js/lib/jquery-1.10.2.min.js"></script>
回答by Brigand
jQuery recently started using source maps.
jQuery 最近开始使用源映射。
For example, let's look at the minified jQuery 2.0.3 file's first few lines.
例如,让我们看看缩小后的 jQuery 2.0.3 文件的前几行。
/*! jQuery v2.0.3 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery.min.map
*/
Excerpt from Introduction to JavaScript Source Maps:
Have you ever found yourself wishing you could keep your client-side code readableand more importantly debuggableeven afteryou've combined and minified it, without impacting performance? Well now you can through the magic of source maps.
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.
你有没有发现自己希望你能保持你的客户端代码可读性更重要的是可调试的,甚至后你 结合和精缩它,而不会影响性能?那么现在你可以通过源映射的魔力了。
基本上这是一种将组合/缩小文件映射回未构建状态的方法。当您为生产构建时,连同缩小和组合您的 JavaScript 文件,您会生成一个源映射,其中包含有关原始文件的信息。当您在生成的 JavaScript 中查询某个行号和列号时,您可以在返回原始位置的源映射中进行查找。开发人员工具(目前是 WebKit nightly builds、Google Chrome 或 Firefox 23+)可以自动解析源映射并使它看起来好像您正在运行未缩小和未组合的文件。
emphasismine
强调我的
It's incredibly useful, and will only download if the user opens dev tools.
它非常有用,只有在用户打开开发工具时才会下载。
Solution
解决方案
Remove the source mapping line, or do nothing. It isn't really a problem.
删除源映射行,或者什么都不做。这真的不是问题。
Side note: your server should return 404, not 500. It could point to a security problem if this happens in production.
旁注:您的服务器应该返回 404,而不是 500。如果在生产中发生这种情况,这可能表明存在安全问题。
回答by Anton Bannikov
I had similar expirience like yours. I have Denwer server. When I loaded my http://new.newlocal site without using via script src jquery.min.js file at index.php in Chrome I got error 500 jquery.min.map in console. I resolved this problem simply - I disabled extension Wunderlist in Chrome and voila - I never see this error more. Although, No, I found this error again - when Wunderlist have been on again. So, check your extensions and try to disable all of them or some of them or one by one. Good luck!
我和你有类似的经历。我有 Denwer 服务器。当我加载我的http://new.new本地站点而不使用通过脚本 src jquery.min.js 文件在 Chrome 中的 index.php 时,我在控制台中收到错误 500 jquery.min.map。我简单地解决了这个问题——我在 Chrome 中禁用了扩展奇妙清单,瞧——我再也没有看到这个错误。虽然,不,我再次发现了这个错误 - 当奇妙清单再次打开时。因此,请检查您的扩展程序并尝试禁用所有扩展程序或其中一些或一个一个。祝你好运!