Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

JS not loading

what am I doing wrong?

function imk_scripts() { wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.3.5', true ); wp_enqueue_script( 'plugin_js', get_template_directory_uri() . '/js/plugins.js', array(''), '1.0', true ); wp_enqueue_script( 'bskit_js', get_template_directory_uri() . '/js/bskit-scripts.js', array(''), '1.0', true ); }

add_action( 'wp_enqueue_scripts', 'imk_scripts' );

Michael Peterman
Michael Peterman
19,087 Points

Hey man, that a little weird. I compared your code with what I usually use and it looks like it should be working. Are you getting any errors in the console (if you right click and go to Inspect Element > Console ) - any 404s?

Here the mistake : there were no script dependencies, so I had to declare empty array: array(), rather than array('').

The correct code is:

function imk_scripts() { wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.3.5', true ); wp_enqueue_script( 'plugin_js', get_template_directory_uri() . '/js/plugins.js', array(), '1.0', true ); wp_enqueue_script( 'bskit_js', get_template_directory_uri() . '/js/bskit-scripts.js', array(), '1.0', true ); } add_action( 'wp_enqueue_scripts', 'imk_scripts'