Benny Posted June 5, 2020 Share Posted June 5, 2020 Hi everyone, I'm new at all this, and just finally hopped onboard gsap with the ScrollTrigger plugin release. But now I've run into a basic installation issue and can't seem to find similar in the forums. This is the only code I've left uncommented for gsap: window.onload = function(){ //timeline functions //HOME PAGE CONDITION if( ishome() ) { //Scroll */ gsap.registerPlugin(ScrollTrigger); I get this error: At the registration call. And the code inside indicates that the body element is undefined: So the problem isn't likely the source files or body tag. The environment is a wordpress install and the files are called with the following enqueue function. As a result of all this trail and error I've tried unminified versions, I've run the files locally instead of CDN, and included map files when calling minified files. I'm running out of ideas. function neon_enqueue() { wp_enqueue_style( 'neon-css', get_template_directory_uri() . '/dist/css/style.css', array(), '1.0.0', 'all' ); //wp_enqueue_script( 'greensock', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/gsap.min.js', array(), '3.3', false ); wp_enqueue_script( 'greensock', get_template_directory_uri() . '/dist/js/gsap.min.js', array(), '3.3', false ); wp_enqueue_script( 'scrolltrigger', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/ScrollTrigger.js', array('greensock'), '3.3', false ); wp_enqueue_script( 'theme-js', get_template_directory_uri() . '/dist/js/theme.js', array(), '1.0.0', false); wp_enqueue_script( 'footer-js', get_template_directory_uri() . '/dist/js/footer.js', array('gs-animation-library'), '1.0.0', true); } I know this is a local environmental issue and not reproducible, but it has to be something really simple I'm not understanding right. Anyone have some insight here? Thanks! Link to comment Share on other sites More sharing options...
Benny Posted June 5, 2020 Author Share Posted June 5, 2020 It was simple. So simple that I'm not sure I should leave the post up but for fellow WP devs just setting this up who load libraries in the header, the ScrollTrigger actually runs the dom so always enqueue in the footer. Not sure if that was mentioned in the docs or not. If it was I missed it. 2 Link to comment Share on other sites More sharing options...
ZachSaucier Posted June 5, 2020 Share Posted June 5, 2020 Hey Benny and welcome to the GreenSock forums. Enqueuing in WP is covered in several threads here on the GSAP forums including 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now