48

Excuse my ignorance but I just installed jQuery using npm and between the jQuery files there's a file called jquery.slim.js, what is slim? I know the min stands for minified but slim is new to me!.

btw I'm pretty sure slim is not like min because there's another file called jquery.slim.min.js and obviously it's lighter than the normal slim file.

Also the slim file contains the jQuery 3 beta. (That's what the comments in the code say)

Again sorry for the stupid question but I got no clue.

UPDATE

I'm using require to include the files, would the require include this file without my knowledge? or not?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Khaled Al-Ansari
  • 3,910
  • 2
  • 24
  • 27
  • 1
    Possible duplicate of [What are the differences between normal and slim package of jquery?](http://stackoverflow.com/questions/35424053/what-are-the-differences-between-normal-and-slim-package-of-jquery) – kapex Mar 02 '16 at 11:14
  • @kapep my question got more details and it's not just about the `slim` version I asked also about the `require` event. Thanks anyway – Khaled Al-Ansari Mar 02 '16 at 11:22

3 Answers3

43

I don't know if .slim.js is a standard name extension for javascript library, but for jQuery, it is a build without some extensions, just check the beginning of the file:

-ajax,-ajax/jsonp,-ajax/load,-ajax/parseJSON,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated

Typically you have no ajax support (jQuery.ajax is not defined), no effects, and the deprecated method are removed.

Concerning requireJS, as far as I know if you require jquery, the only file "included" will be jquery.js, so you would have to explicitely require jquery.slim in order to get jquery.slim.js file included, which is not what you want.

Khaled Al-Ansari
  • 3,910
  • 2
  • 24
  • 27
Holt
  • 36,600
  • 7
  • 92
  • 139
  • Do you have any idea if this a build by the devs of jQuery, or if this some third party lib? I cannot seem to find any information regarding it - only a slim version on cdnjs, but not even on their own CDN. – Bram Vanroy Mar 02 '16 at 10:59
  • If there's no `ajax` then why this file is there? I'm asking because one of the main purposes that I'm using jQuery is the `ajax` function – Khaled Al-Ansari Mar 02 '16 at 11:00
  • 2
    @KhaledAl-Ansari Lots of people use jQuery for DOM manipulation (`$()`) and do not care about AJAX or custom effects. If you want to use `jQuery.ajax`, do not use this file. – Holt Mar 02 '16 at 11:01
  • I'm depending on requireJS for the include, would requireJS include this file without my knowledge? – Khaled Al-Ansari Mar 02 '16 at 11:02
  • 1
    @BramVanroy I think it is build by jQuery's devs since the [`build/release.js`](https://github.com/jquery/jquery/blob/master/build/release.js) file on the official github repository contains information to build it. – Holt Mar 02 '16 at 11:02
  • @KhaledAl-Ansari I am not using requireJS myself so I cannot say for sure but I think it is very unlikely. – Holt Mar 02 '16 at 11:04
  • @KhaledAl-Ansari According to requireJS doc, except if you specify it explicitely (by requiring `jquery.slim` or `jquery.slim.min`), only `jquery.js` file will be included. – Holt Mar 02 '16 at 11:08
  • Cool! can you please update your answer so I can verify it – Khaled Al-Ansari Mar 02 '16 at 11:09
2

THE SLIM VERSION – CONS Possible compatibility issues Even though jQuery Slim 3.0 is an ‘official’ release, its relative newness ensures that plugin and framework vendors have not had particularly much time to adapt their products to the feature set. If your company is currently going through a rocky transition adapting its products to jQuery 3.0, adding the extra grief caused by a deployment of the slim version is unlikely to be worth it. Problems caused by missing or incomplete implementations of support libraries tend to be among the most difficult to debug. Avoiding them is recommended to experienced and novice developers.

Deploying jQuery Slim saves you the princely sum of 6KB: many applications waste more than that on in-line comments in the markup. Of course, compile and parse time is also reduced – but does that really matter in a time when an octacore smartphone can be bought for fewer than 200 euros?

Original Source

Assil
  • 572
  • 6
  • 21
  • 2
    Sometimes it's just about having "less moving parts" , not file size. The more parts in a machine, the more things that can go wrong. I am writing a resume in jquery today. Going to try out jquery.slim.js – KANJICODER Aug 31 '20 at 13:45
0

it is a jquery with less features, features that i needed so i gave up. your mileage may vary, but fairly, .slim.min was only 6kB less than just .min.

alex
  • 651
  • 1
  • 9
  • 11