Enqueue GSAP and ScrollTrigger

User
https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/gsap.min.js
https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/ScrollTrigger.min.js
add this via wp_enqueue
Assistant
You can enqueue GSAP and ScrollTrigger in WordPress using `wp_enqueue_script()`. Add the following code to your theme's `functions.php` file:

### Enqueue GSAP and ScrollTrigger in WordPress:

function enqueue_gsap_scripts() {
    wp_enqueue_script('gsap', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/gsap.min.js', array(), '3.4.2', true);
    wp_enqueue_script('scrolltrigger', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/ScrollTrigger.min.js', array('gsap'), '3.4.2', true);
}
add_action('wp_enqueue_scripts', 'enqueue_gsap_scripts');

### Explanation:
– `wp_enqueue_script('gsap', 'URL', array(), 'version', true);`
– Loads **GSAP** from the CDN.
– `true` ensures it loads in the footer for better performance.

– `wp_enqueue_script('scrolltrigger', 'URL', array('gsap'), 'version', true);`
– Loads **ScrollTrigger** after GSAP (dependency is set as `'gsap'`).

This ensures GSAP and ScrollTrigger are loaded correctly in your WordPress site. ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *