I am trying to develop my first Wordpress Theme and I'm having trouble loading a couple of javascript files inside my child theme's functions.php file. I must be missing something as my script isn't running but I'm fairly positive my syntax is correct.
Here is the code I have added to my functions.php file in my child theme. It loads a javascript animation library and then my custom script, none of which rely on jQuery.
add_action('wp_enqueue_scripts', 'custom_theme_scripts');
function custom_theme_scripts() {
wp_register_script('GSAP','http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenLite.min.js', true);
wp_register_script('Animations', get_stylesheet_directory_uri() . '/animation.js', true);
wp_enqueue_script('GSAP');
wp_enqueue_script('Animations');
}
This is my custom script targeting a .svg element on the page with an id of "logo"
window.onload = function() {
var logo = document.getElementById("logo");
TweenLite.to(logo, 1.5, { width:5000 });
};