Jump to content
Search Community

Gsap not defined

AlecV test
Moderator Tag

Recommended Posts

Every time I try to register a plugin using gsap.registerPlugin() the console always comes back with an error saying gsap is not defined.

The console does retrieve the the plugin file from it's destination so I don't know what could be going wrong.

 

Any help?

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

My best guess is that you are executing your code before you ever even loaded GSAP. For example: 

<script>
  // uh oh, GSAP isn't even loaded yet!
  gsap.registerPlugin(ScrollTrigger);
  ...
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/ScrollTrigger.min.js"></script>

 

In that case, you'd just need to move the <script> tags that are loading GSAP files ABOVE where your code is. Or you could wrap your code in a DOMContentLoaded event handler so that it waits. 

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

 

If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

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