在CDNJS jquery。纤细的包裹被放置。它的尺寸更小。与原作的主要区别是什么?快速查看代码并没有带来答案,在https://jquery.com我没有找到任何关于苗条包的参考资料。
那么,jquery.js和jquery.slim.js之间有什么区别呢?
在CDNJS jquery。纤细的包裹被放置。它的尺寸更小。与原作的主要区别是什么?快速查看代码并没有带来答案,在https://jquery.com我没有找到任何关于苗条包的参考资料。
那么,jquery.js和jquery.slim.js之间有什么区别呢?
当前回答
下面是jQuery 3.0最终版发布公告中的简短回答:
除了包含ajax和effects模块的常规jQuery版本外,我们还发布了一个不包含这些模块的“精简”版本。总而言之,它排除了ajax、特效和当前已弃用的代码。
文件大小(gzip)大约小了6k, 23.6k vs 30k。
其他回答
下面是jQuery 3.0最终版发布公告中的简短回答:
除了包含ajax和effects模块的常规jQuery版本外,我们还发布了一个不包含这些模块的“精简”版本。总而言之,它排除了ajax、特效和当前已弃用的代码。
文件大小(gzip)大约小了6k, 23.6k vs 30k。
我能看到美元。从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 */
如上所述,Ajax和特效模块已经被排除在jQuery slim之外,缩小版解压后的尺寸差异为85k vs 69k(精简版节省16k)或压缩版30vs24,需要注意的是,bootstrap 4使用的是精简版jQuery,所以如果有人想要完整版,他们需要调用它
目前,最权威的答案似乎在这个问题上,它说“这是一个jQuery的自定义构建,排除了效果,ajax和弃用代码。”具体细节将在jQuery 3.0发布。
我怀疑排除jQuery库中的这些组件的基本原理是认识到jQuery与其他JS框架(如Angular或React)结合使用的情况越来越普遍。在这些情况下,jQuery主要用于DOM遍历和操作,因此去掉那些过时的或由框架提供的组件可以使文件大小减小20%左右。
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.