Jump to content
Search Community

Lighten library in production

Alle test
Moderator Tag

Recommended Posts

Hello,
I have a question.


I am using vue 3 and i imported:
import gsap from 'gsap';.

 

Finally I have a simple animation like:
gsap.to('.logo-navbar', { y: 0, duration: 0.3 });
So a simple motion.


Now to make this simple animation I am loading the whole gsap library, this weighs down the production i file.

Is there any way to use only a part of the library? 

The goal is to keep the animation without loading the whole library.


I have tried various experiments like :
import { to, from } from 'gsap';
import { to as gsapTo, from as gsapFrom } from 'gsap';


But it doesn't work for me or I am not able to make it work.

 

Thank you and have a nice day.
 

Link to comment
Share on other sites

Hi @Alle. The short answer is "no", sorry. We've put a lot of thought into the GSAP core and how to package things in a way that'd maximize flexibility, performance, reliability, and developer ergonomics. In the old days, we split things apart into TweenLite, TweenMax, TimelineLite, and TimelineMax, for example, and ultimately it led to a lot of confusion and hassle. So we simplified the API, consolidated into a single "gsap" object, and put all the essentials there so that you can reliably leverage them wherever you want. 

 

Honestly, for the vast majority of users out there, the GSAP library would load in a matter of milliseconds, so the practical difference between loading the core and splitting out some simplified version for you wouldn't even be noticeable. Plus if we offered custom chunks like that, it'd ruin a lot of the benefits you can get from caching and GSAP's core being so ubiquitous. 

 

And let's be honest...you might be only doing a simple animation right now, but once you get a taste of GSAP you're gonna be using it all over the place, so might as well just bite the bullet and load the file 🤣

  • Like 1
Link to comment
Share on other sites

Hello and thank you for your response.


I have been using gsap for 3 years and I am very satisfied.

Actually my question was a question to understand if it could be done.

I have always loaded the whole library and indeed it loads very fast.

I have nothing more to add it was just a curiosity.

I will continue to use this great library even when I have to do simple animations.

Thank you as always for your intervention.


I wish everyone a good day.

Alessandro

Excuse my italianized English.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...