Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Classes instead of UMD #1281

Open
mountwo23 opened this issue Jul 19, 2023 · 1 comment
Open

Convert to Classes instead of UMD #1281

mountwo23 opened this issue Jul 19, 2023 · 1 comment

Comments

@mountwo23
Copy link

mountwo23 commented Jul 19, 2023

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
Copy link
Author

mountwo23 commented Aug 2, 2023

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

  • more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant