Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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'