On the frontend of your website, check the browser dev tools Network panel and make sure your GSAP CDN script is being run/loaded before your custom GSAP script JS file. This way your custom code runs after GSAP is already loaded
Also you might have to add a DOM ready event and window load event to make sure your code is running when the HTML markup (DOM) and window is fully loaded.
// wait until DOM is ready
document.addEventListener("DOMContentLoaded",function(event){
console.log("DOM loaded");// wait until images, links, fonts, stylesheets, and js is loaded
window.addEventListener("load",function(e){// custom GSAP code goes here
console.log("window loaded");},false);});
Check your dev tools console to make sure you see those output console logs.
<?php
// The proper way to enqueue GSAP script// wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );function theme_gsap_script(){
wp_enqueue_script('gsap-js','http://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.1/TweenMax.min.js', array(),false,true);
wp_enqueue_script('gsap-js2', get_template_directory_uri().'/js/custom-gsap-scripts.js', array(),false,true);}
add_action('wp_enqueue_scripts','theme_gsap_script');?>
The link to the WordPress Codex for enqueuing JS files:
Thank you jake jake-adams - you helped me a lot. I am grateful. I knew it was a scripting issue with wordpress. Been looking for this answer everywhere. Nowhere on the internet can you find the correct way. ONCE AGAIN - AMAZING JOB. Issue Solved.
WordPress 5 integration
in GSAP
Posted
Thank you jake jake-adams - you helped me a lot. I am grateful. I knew it was a scripting issue with wordpress. Been looking for this answer everywhere. Nowhere on the internet can you find the correct way. ONCE AGAIN - AMAZING JOB. Issue Solved.