0

Please help with console error: Uncaught ReferenceError: gsap is not defined I include GSAP with cdn by:

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
<script src="js/index.min.js"></script>

And using it in js file:

gsap.registerPlugin(ScrollTrigger);
gsap.to('.laptop__top', {
scrollTrigger: {
    trigger: '.laptop',
    start: '20px top',
    end: '250px top',
    // markers: true,
    scrub: 2.5,
},
rotationX: 0,
duration: 5,

});

But anywhere get error.

5
  • 1
    It shouldn't be undefined with the scripts in that order (I just checked in a stack snippet). It sounds like some other error (a 404? 500?) has occurred and this is a follow-on from that. Commented Oct 20, 2021 at 17:45
  • Make sure the first script is actually loaded properly. Commented Oct 20, 2021 at 17:47
  • Add a defer to your script tag <script src = "" defer></script>
    – AnanthDev
    Commented Oct 20, 2021 at 17:48
  • 1
    Make sure to also load ScrollTrigger before your script that uses it. Commented Oct 21, 2021 at 12:43
  • kindly put your code inside "document ready" function Commented Jun 22, 2022 at 15:42

1 Answer 1

1

Add this CDN below your current Gsap CDN

https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js (make sure the CDN versions are the same)

Ref: https://gsap.com/docs/v3/Installation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.