有的網站,引入的是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,這是個瘦身版。