twitter-bootstrap 为什么 Bootstrap 尝试在 Edge 中加载 LESS 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35142485/
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
Why is Bootstrap trying to load LESS files in Edge?
提问by huertanix
I have a web page using Twitter Bootstrap. It works well in Chrome, Firefox, and Safari. However, when I try to view it in Edge on Windows 10, I get a bunch of 403 errors saying it failed to load a slew of .less files from the Bootstrap CDN. Why are .less files being requested if the browser can't do anything with them? I am not using LESS at all, just plain CSS3, which is rendering just fine. How do I make this stop?
我有一个使用 Twitter Bootstrap 的网页。它在 Chrome、Firefox 和 Safari 中运行良好。但是,当我尝试在 Windows 10 上的 Edge 中查看它时,我收到一堆 403 错误,说它无法从 Bootstrap CDN 加载大量 .less 文件。如果浏览器不能对它们做任何事情,为什么会请求 .less 文件?我根本没有使用 LESS,只是简单的 CSS3,渲染得很好。我该如何停止?
回答by Martin Beeby
The good news is this won't be affecting regular users of the site. The bad news is this is also happening in Chrome to some extent, it's just that the network tab in Chrome isn't reporting the 403 errors.
好消息是这不会影响该网站的普通用户。坏消息是这在某种程度上也发生在 Chrome 中,只是 Chrome 中的网络选项卡没有报告 403 错误。
In the CSS file that you link to there is a line at the bottom of the file:
在您链接到的 CSS 文件中,文件底部有一行:
/*# sourceMappingURL=bootstrap.min.css.map */
This is the source maps and gives links to all the source files used to generate the minified CSS that is in your browser.
这是源映射并提供指向用于生成浏览器中的缩小 CSS 的所有源文件的链接。
In the bootstrap instance the CDN is pointing to files that do not exist such as http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/less/scaffolding.less
在引导程序实例中,CDN 指向不存在的文件,例如http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/less/scaffolding.less
The source map file will only be downloaded if you have source maps enabled and your dev tools open. Edge defaults source maps on and as far as I can tell there is no way to switch them off (but remember this will only happen when the dev tools are open, I have confirmed this behaviour using Fiddler), so when you press f12 then it's going to try and fetch the source mapped files. Chrome works slightly differently, it will download the source map but then will not attempt to download the .less file until you navigate to the source file.
只有在启用了源映射并且打开了开发工具的情况下才会下载源映射文件。Edge 默认源映射打开,据我所知没有办法关闭它们(但请记住,这只会在开发工具打开时发生,我已经使用 Fiddler 确认了这种行为),所以当你按 f12 时将尝试获取源映射文件。Chrome 的工作方式略有不同,它会下载源地图,但在您导航到源文件之前不会尝试下载 .less 文件。
If one of the .less files is returning a 403 Forbidden response Edge reports this in the network tab. Chrome dosen't.
如果 .less 文件之一返回 403 Forbidden 响应,Edge 会在网络选项卡中报告此情况。铬不。
If you use http debugger such as Fiddler you will see that Chrome does indeed request the files and also gets a 403 response, however, it doesn't report it on the network tab. When using Fiddler to get past the https issue I changed the CSS file to point to the non https URL. e.g: http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css
如果您使用诸如 Fiddler 之类的 http 调试器,您会看到 Chrome 确实请求文件并获得 403 响应,但是,它不会在网络选项卡上报告它。当使用 Fiddler 解决 https 问题时,我将 CSS 文件更改为指向非 https URL。例如:http: //maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css
The fix for this issue is to fix the files that are 403'ing in the source map. I have raised an issue on the bootstrap maxcdn GitHub repro: https://github.com/MaxCDN/bootstrap-cdn/issues/629
此问题的修复方法是修复源映射中的 403 文件。我在 bootstrap maxcdn GitHub repro 上提出了一个问题:https: //github.com/MaxCDN/bootstrap-cdn/issues/629
回答by xameeramir
There is a known issue with MaxCDNitself. (and CDNjsas well)
Logged issues for reference:
记录问题以供参考:
https://github.com/MaxCDN/bootstrap-cdn/issues/671- This issue is closed as duplicate
https://github.com/MaxCDN/bootstrap-cdn/issues/629- known bug
https://github.com/twbs/bootstrap/issues/19063- open issue with Twitter bootstrap
https://github.com/MaxCDN/bootstrap-cdn/issues/671- 此问题已重复关闭
https://github.com/twbs/bootstrap/issues/19063- Twitter 引导程序的未解决问题
CDN analysis:
CDN分析:
For sourceMappingURLwhich is bootstrap.min.css.mapfor bootstrap file, any of the .lessextension files (e.g. this file) are failing to load with HTTP status 403(forbidden).
为sourceMappingURL这是bootstrap.min.css.map为引导文件,任何的.less扩展名的文件(例如文件)没有能够负载,HTTP状态403(禁止)。
Chrome is supressing this issue in the developer console, however Edge is not. The issue when accessing the .less files is reproduceable by accessing thislink.
Chrome 在开发者控制台中抑制了这个问题,但 Edge 没有。访问 .less 文件时的问题可通过访问此链接重现。
This issue is not only with MaxCDN, but also with CDNjs. The links for CDNjs are this,this& this


