Jump to content
Search Community

Wordpress Gsap Integration

dileepkp123 test
Moderator Tag

Recommended Posts

Hi everyone,

 

I`m completely new to GreenSock and I`d like to learn how to integrate it in WordPress 5. I'm working on a WP website and I'm developing my own child theme. But Its not working its shows   "uncaught referenceerror $ is not defined "

 

This is my function.php

 

wp_enqueue_script'gsap-js''https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js'array(), falsetrue );
   wp_enqueue_script'gsap-js''http://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js'array(), falsetrue );
   wp_enqueue_script'gsap-js''//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js'array(), falsetrue );
 
   wp_enqueue_script'gsap1-js''https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TimelineLite.min.js'array(), falsetrue );
   
   wp_enqueue_script'gsap2-js''https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/plugins/CSSPlugin.min.js'array(), falsetrue );
   
   wp_enqueue_script'gsap3-js''https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/easing/EasePack.min.js'array(), falsetrue );
 
   
Link to comment
Share on other sites

Hey dileepkp123 and welcome to the GreenSock forums!

 

First off, that error has nothing to do with GSAP. It likely means that you are trying to use jQuery but are not loading it correctly (if at all). Loading jQuery before the script that is attempting to use it should fix that error.

 

Secondly, you are attempting to use two really old versions of GSAP. We highly recommend using GSAP 3. You can use the URL here: https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js

 

If you use GSAP 3, you don't have to load TweenMax, TimelineLite, CSSPlugin, or likely EasePack (unless you need the eases included in it). Thus you can replace all of the code above with the following:

wp_enqueue_script( 'gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js', array(), false, true );

 

It's hard for us to help much more than that given we cannot see your setup. But please let us know if you have questions and we'll be happy to help however we can!

  • Like 1
Link to comment
Share on other sites

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