February 28, 2018
I’ve been running into “Uncaught referenceError: jQuery is not defined” a lot lately when working with scripts and plugins that I’ve used for years. It’s unbelievably annoying to have something that’s worked one way for most of my career to suddenly stop working and bring up errors.
Nonetheless, I’ve found a solution!
function theme_scripts() {
// slick slider
wp_register_script('slick',get_bloginfo('stylesheet_directory').'/js/slick/slick.min.js', array( 'jquery' ));
wp_enqueue_script('slick');
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
Add array(‘jquery’) to enqueued scripts to tell the function that the script relies on jQuery and to load it after jquery.js in your WordPress install.
Sourced here.