在CDNJS jquery。纤细的包裹被放置。它的尺寸更小。与原作的主要区别是什么?快速查看代码并没有带来答案,在https://jquery.com我没有找到任何关于苗条包的参考资料。

那么,jquery.js和jquery.slim.js之间有什么区别呢?


当前回答

目前,最权威的答案似乎在这个问题上,它说“这是一个jQuery的自定义构建,排除了效果,ajax和弃用代码。”具体细节将在jQuery 3.0发布。

我怀疑排除jQuery库中的这些组件的基本原理是认识到jQuery与其他JS框架(如Angular或React)结合使用的情况越来越普遍。在这些情况下,jQuery主要用于DOM遍历和操作,因此去掉那些过时的或由框架提供的组件可以使文件大小减小20%左右。

其他回答

我能看到美元。从jQuery中移除ajax

来自jQuery文档

你也可以使用精简版,它排除了ajax和效果模块

以下是精简版删除功能后的评论

/*! jQuery v3.2.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector | (c) JS Foundation and other contributors | jquery.org/license */

我刚刚发现,一个元素属性的选择器不会与slim工作。

$('input[type="textarea"]').each(function(index) {});

希望这对你有所帮助。

下面是jQuery 3.0最终版发布公告中的简短回答:

除了包含ajax和effects模块的常规jQuery版本外,我们还发布了一个不包含这些模块的“精简”版本。总而言之,它排除了ajax、特效和当前已弃用的代码。

文件大小(gzip)大约小了6k, 23.6k vs 30k。

查看代码,我发现jquery.js和jquery.slim.js之间有以下差异:

在jquery.slim.js中,删除了以下特性:

jQuery.fn.extend jquery.fn.load jquery。每个(附加一堆处理常见AJAX事件的函数) jQuery.expr.filters.animated AJAX设置(jQuery.ajaxSettings。xhr, jQuery。ajaxPrefilter, jQuery。ajaxSetup, jQuery。ajaxPrefilter jQuery.ajaxTransport) XML解析,jQuery.parseXML 动画效果(jQuery。宽松,jQuery。动画,jQuery.speed)

jQuery博客,jQuery 3.1.1发布!说,

Slim build Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version – 23.6k vs 30k.