有的网站,引入的是jquery.slim.js 而非jquery.js,比如 bootstrap 4 官方手册中默认使用的就是slim版本。
那么,jquery.slim.js与jquery.js有什么区别?
slim,即苗条的; 纤细的。
jquery.slim.js即简化版的jquery.js。
看官方描述:
有时您不需要ajax,或者您更喜欢使用许多专注于ajax请求的独立库之一。
通常,对所有Web动画使用CSS和类操作的组合会更简单。与包括ajax和effects模块的jQuery常规版本一起,我们发布了一个“ slim”版本,其中不包括这些模块。总而言之,它不包括ajax,效果和当前不建议使用的代码。如今,jQuery的大小很少会涉及到负载性能,但是苗条的构建比常规版本小6k gzip压缩字节,即23.6k vs 30k。
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.
JQuery.slim.js去掉了Ajax部分和特效(effects),体积变小了。如果你不需要用到ajax,或者使用了独立的第三方ajax库,就可以使用这个jquery.slim.js,这是个瘦身版。