What’s going on here?

[ad_1]

The below code is taken from the [GSPAP documentation page on installing gsap in WordPress]).

< ? php
// The proper way to enqueue GSAP script in WordPress

// wp\_enqueue\_script( $handle, $src, $deps, $ver, $in\_footer );
function theme\_gsap\_script(){
// The core GSAP library
wp\_enqueue\_script( ‘gsap-js’, ‘https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js’, array(), false, true );
// ScrollTrigger – with gsap.js passed as a dependency
wp\_enqueue\_script( ‘gsap-st’, ‘https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/ScrollTrigger.min.js’, array(‘gsap-js’), false, true );
// Your animation code file – with gsap.js passed as a dependency
wp\_enqueue\_script( ‘gsap-js2’, get\_template\_directory\_uri() . ‘js/app.js’, array(‘gsap-js’), false, true );
}
add\_action( ‘wp\_enqueue\_scripts’, ‘theme\_gsap\_script’ );
?>

I’m used to first registering a script and then enqueing. So my version of the above would be this:

if (!function_exists(‘my_scripts’)) {
function my_scripts()
{
// The core GSAP library
wp_enqueue_script( ‘gsap-js’, ‘https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js’, array(), false, true );
wp_enqueue_script(‘gsap-js’);

// ScrollTrigger – with gsap.js passed as a dependency
wp_enqueue_script( ‘gsap-st’, ‘https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/ScrollTrigger.min.js’, array(‘gsap-js’), false, true );
wp_enqueue_script(‘gsap-st’);

// Your animation code file – with gsap.js passed as a dependency
wp_enqueue_script( ‘gsap-js2’, get\_template\_directory\_uri() . ‘js/app.js’, array(‘gsap-js’), false, true );
wp_enqueue_script(‘gsap-js2’);

}
add_action(‘wp_enqueue_scripts’, ‘my_scripts’);
}

It it possible to reference and enqueue a script at the same time as the code from the GSAP docs seem to be doing? Also, what’s with the backslashes?

Thanks for any input.

&#x200B;

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer