本文介绍了为什么使用jquery map?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么要使用 jquery.min.map if:

  jquery = 242 ko 
jquery.min + jquery.min.map = 83 + 125 = 208 ko(地图甚至比图书馆还要大)

如果我们删除注释,我们将得到一个更容易阅读(和调试)的小jquery。



map 如果只添加超过 100 ko 和一个额外的请求?



最佳做法是什么?



解决方案

仅在开发人员工具处于活动状态时加载源地图。浏览器不会为应用程序的用户加载它们。



编辑:应该提到有两种类型的源地图。一个是外部文件,在实际文件中有一个链接,另一个嵌入在主文件中。浏览器实际上必须为第二种类型加载整个文件(即包括嵌入的源映射)。



检查了解更多信息。


Why using jquery.min.map if:

jquery = 242 ko
jquery.min + jquery.min.map = 83 + 125 = 208 ko (the map is even greater than the library)

And if we remove the comments, we will get a small jquery that could be easier to read (and to debug).

So, why using the map if it will only add more than 100 ko and an extra request?

What is the best practice?

解决方案

Source maps are loaded only when the developer tools are active. Browsers won't load them for application's users.

Edit: It should be mentioned that there are 2 types of source maps. One which is an external file and there is a link to it in the actual file and another one which is embedded in the main file. Browsers actually have to load the entire file (i.e. including the embedded source map) for the second type.

Check https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ for more information.

这篇关于为什么使用jquery map?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:15