metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.5k stars 604 forks source link

Convert to Classes instead of UMD #1281

Open mountwo23 opened 1 year ago

mountwo23 commented 1 year ago

Do you have any plans to transition to the class syntax instead of UMD? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes It would reduce the size of the files by a significant amount which would help compete with all the other slideshow js projects. The only reason I stayed with Flickity was the fullscreen implementation as the others did not have it. I was hesitant at first as flickity was slightly bigger that other ones but i think its possible to reduce it down to around 20 - 30 KB or even less if done right.

I use a custom PHP JavaScript compressor that converts constants, functions, and classes into corresponding letters in the alphabet. This approach helps me further reduce the size of my JavaScript files without compromising maintainability. However, I'm facing difficulties applying this compression technique to the Flickity JavaScript file since it utilizes UMD. As a result, I'm currently in the process of converting the Flickity codebase into classes, which seems feasible. Nonetheless, I wanted to reach out and inquire about your plans.

Additionally, it would be great to have an option to remove certain features from the packaged file, such as JQuery Bridget.

mountwo23 commented 12 months ago

I've spent around 100 hours compressing my version of Flickity by removing unnecessary elements and improving the code. I managed to reduce it from 60 KB to 8 KB without even gzipping. However, it's heavily mangled and will only work with my project. Otherwise, it would be around 10 KB. I think it would be great to see a complete rewrite in Flickity V3. Around 3.6 KB when gzipped Here are the changes I made:

Removed EventEmitter Removed Utils Combined LazyLoader with ImageLoader Removed GroupCells (I don't need it) Converted UMD to Class Notation Removed jQuery Removed HTML initializer