0

usphilatelics.com is my first website containing javascript, and I'm having difficulty getting the script to load at the end of the page. I originally wrote all the js within the header.php, so of course it is loaded first in the browser. I have now copied the script into an external file, but cannot get it to load. In functions.php I have added :

function wp_adding_vsb_scripts() {
//echo get_stylesheet_directory_uri();
wp_register_script('vsb_script', get_stylesheet_directory_uri() . '/custom-js/vsb.js', array( 'jquery'), '1.1', true);
wp_enqueue_script('vsb_script');
}

add_action( 'wp_enqueue_scripts', 'wp_adding_vsb_scripts' );

It is picking up the correct directory for the child theme I am using, but does not include the script anywhere that I can see. What else do I need to do, where am I going wrong ?

For the time being, I have left the code in the header so that the site works.

  • 1
    do you have wp_head(); in your header.php? – David Lee Aug 29 '17 at 15:13
  • When I look at your site using google developer tools I see the js file being loaded. The file path is: http://usphilatelics.com/wp-content/themes/sparkling-child/custom-js/vsb.js This appears to be working. You have other jQuery issues however. – Jeff Mattson Aug 29 '17 at 15:53
  • Yes, I do have wp_head(); in header.php, immediately before the </head>. – BeeJayEff Aug 30 '17 at 17:15
  • Can you clarify what jQuery issues I have ? – BeeJayEff Aug 30 '17 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.