What are the differences between normal and slim package of jquery?

JquerySlim Jquery

Jquery Problem Overview


At CDNJS jquery.slim package is placed. It has a smaller size. What are the major differences from an original? A quick look at the code didn't bring the answer, and at the https://jquery.com I've not found any reference about slim package.

So, what are the differences between jquery.js and jquery.slim.js?

Jquery Solutions


Solution 1 - Jquery

The short answer taken from the announcement of jQuery 3.0 Final Release :

> Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code.

The file size (gzipped) is about 6k smaller, 23.6k vs 30k.

Solution 2 - Jquery

Looking at the code I found the following differences between jquery.js and jquery.slim.js:

In the jquery.slim.js, the following features are removed:

  1. jQuery.fn.extend
  2. jquery.fn.load
  3. jquery.each (attach a bunch of functions for handling common AJAX events)
  4. jQuery.expr.filters.animated
  5. AJAX settings (jQuery.ajaxSettings.xhr, jQuery.ajaxPrefilter, jQuery.ajaxSetup, jQuery.ajaxPrefilter, jQuery.ajaxTransport)
  6. XML parsing (jQuery.parseXML),
  7. Animation effects (jQuery.easing, jQuery.Animation, jQuery.speed)

Solution 3 - Jquery

At this time, the most authoritative answer appears to be in this issue, which states "it is a custom build of jQuery that excludes effects, ajax, and deprecated code." Details will be announced with jQuery 3.0.

I suspect that the rationale for excluding these components of the jQuery library is in recognition of the increasingly common scenario of jQuery being used in conjunction with another JS framework like Angular or React. In these cases, the usage of jQuery is primarily for DOM traversal and manipulation, so leaving out those components that are either obsolete or are provided by the framework gains about a 20% reduction in file size.

Solution 4 - Jquery

The jQuery blog, jQuery 3.1.1 Released!, says,

> 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.

Solution 5 - Jquery

I could see $.ajax is removed from jQuery slim 3.2.1

From the jQuery docs

> You can also use the slim build, which excludes the ajax and effects modules

Below is the comment from the slim version with the features removed

/*! 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 */

Solution 6 - Jquery

As noted the Ajax and effects modules have been excluded from jQuery slim the size difference as of 3.3.1 for the minified version unzipped is 85k vs 69k (16k saving for slim) or 30vs24 for zipped, it is important to note that bootstrap 4 uses the slim jQuery so if someone wants the full version they need to call that instead

Solution 7 - Jquery

There was a big difference when I wanted to use jQuery UI With the slim version of jQuery, it is impossible. In fact, the slim version excludes the ajax and effects modules

Solution 8 - Jquery

I found a difference when creating a Form Contact: slim (recommended by boostrap 4.5):

  • After sending an email the global variables get stuck, and that makes if the user gives f5 (reload page) it is sent again. min:
  • The previous error will be solved. how i suffered!

Solution 9 - Jquery

i've just found out that a selector by an element attribute won't work with slim.

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

hope this may help you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSynCapView Question on Stackoverflow
Solution 1 - JqueryJannie TheunissenView Answer on Stackoverflow
Solution 2 - JqueryBhojendra RauniyarView Answer on Stackoverflow
Solution 3 - JquerygxclarkeView Answer on Stackoverflow
Solution 4 - JqueryChrisWView Answer on Stackoverflow
Solution 5 - JquerykiranvjView Answer on Stackoverflow
Solution 6 - JqueryYehuda SchwartzView Answer on Stackoverflow
Solution 7 - JqueryDarsaveliView Answer on Stackoverflow
Solution 8 - JqueryJuan Silupú MazaView Answer on Stackoverflow
Solution 9 - JqueryalexView Answer on Stackoverflow