Sortable: v1.7.0 to v1.8.3: library size increased +70%

Created on 23 Feb 2019  路  3Comments  路  Source: SortableJS/Sortable

I can see that a lot of effort went into v1.8. The size of Sortable.js however went from 37Kb for v1.7.0 to 63Kb for v1.8.3, a +70% increase.

Size does matter, at least for user experience and SEO. Google for instance is fairly stringent with websites taking long to load (e.g. due to downloading and parsing big Javascripts).

Maybe there are too many options and too much logic being added in the component?
Or maybe the more exotic functionality could be kept as an optional extension?

As you see I do not have a specific solution to propose, I just feel that the code is becoming too bulky and complex. This issue is to get the conversation rolling. Thanks at any rate for maintaining Sortable.

Most helpful comment

Thanks for considering this. If you are thinking about different builds, then I would suggest to go all the way to add-ons (core Sortable.js + additional Sortable-addonX.js):

  • allows developers to cherry-pick what add-ons they want instead of being restricted to the combinations in available builds
  • helps keep the code more maintainable: functionality in an add-on is clearly separated and only dependent on the core Sortable class

55% is still significant, but comments are good and I noticed (and appreciate) the fixes brought by v1.8 :-)

All 3 comments

Yes a lot was added, but most of it was very necessary. However, a lot of the size increase may be due to added comments. Take a look at Sortable.min.js. The current version is 23.9kb and 1.7.0 was 15.4kb - a 55% increase only. You should (obviously) use this one if you are concerned about file size.

I suppose future versions could include different builds that are stripped of certain features, such as the upcoming multi drag and swap features.

Thanks for considering this. If you are thinking about different builds, then I would suggest to go all the way to add-ons (core Sortable.js + additional Sortable-addonX.js):

  • allows developers to cherry-pick what add-ons they want instead of being restricted to the combinations in available builds
  • helps keep the code more maintainable: functionality in an add-on is clearly separated and only dependent on the core Sortable class

55% is still significant, but comments are good and I noticed (and appreciate) the fixes brought by v1.8 :-)

I also echo support for this. According to https://bundlephobia.com/[email protected] - the Library size substantially increased from version 1.7.0 to 1.8.0 by approx 8.5KB (this is without any comments, minified).

Version 1.8.4 current size:

image

It's worth noting that the most important factor is NOT the gzipped size but the unzipped size. Why? Because the browser has to PARSE the unzipped size, not the gzipped size. So although download time is reduced with better gzip, if the size unzipped is large then browser takes longer to parse js.

I would personally like to see the ability for this library to be more modern and tree-shakeable, so you can import just the functionality you need:

import { Core, MultiDrag, AdvancedAnimations } from 'sortablejs';

...or something simiar. Essentially, just break up the code into seperate modules to allow the code to be tree shakeable.

Was this page helpful?
0 / 5 - 0 ratings