Jump to content
Search Community

Gsap is not defined

marcow test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

I have this error that I see in the chrome console and I don't understand the problem.
The gsap-core script and scroll trigger are installed correctly as you can see from the screenshot of the html of the page, I inserted the urls in cdn from the installation page.
Opening the js file where I have inserted the gsap code seems not to find Scrollrtrigger plugin.
I can't figure out what the problem is.

 

Error-Console.png

Link to comment
Share on other sites

  • Solution

Hi @marcow welcome to the forum!

 

From your screenshot I see you load your motion-gsap.js BEFORE all the GSAP scripts. It is recommended too load your own script AFTER all the dependencies you'll need. 

 

As a work around you can wrap your custom code in a load listener eg that way you're sure your code gets executed when everything on the page has load. 

 

window.addEventListener("load", (event) => {

  // your code here!
  
});

Hope it helps and happy tweening! 

  • Like 1
Link to comment
Share on other sites

9 minutes ago, mvaneijgen said:

Hi @marcow welcome to the forum!

 

From your screenshot I see you load your motion-gsap.js BEFORE all the GSAP scripts. It is recommended too load your own script AFTER all the dependencies you'll need. 

 

As a work around you can wrap your custom code in a load listener eg that way you're sure your code gets executed when everything on the page has load. 

 

window.addEventListener("load", (event) => {

  // your code here!
  
});

Hope it helps and happy tweening! 

Thanks!! so it works, I moved my motion-gsap.js code underneath and everything works correctly.

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