Problem: My custom.js is loading before jquery and throwing an error.
My functions.php code setup:
function blue_sentry_scripts() {
wp_enqueue_style( 'blue-sentry-style', get_stylesheet_uri() );
wp_enqueue_script( 'blue-sentry-superfish', get_template_directory_uri() . '/js/superfish.min.js', array('jquery'), '20141010', true );
wp_enqueue_script( 'blue-sentry-superfish-settings', get_template_directory_uri() . '/js/superfish-settings.js', array('blue-sentry-superfish'), '20141010', true );
wp_enqueue_script( 'blue-sentry-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'blue-sentry-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
wp_enqueue_script( 'skrollr', get_template_directory_uri() . '/js/skrollr.min.js', array(), '20140928', true );
wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints.min.js', array('jquery'), '20141022', true );
wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/custom.js', array('jquery','waypoints'), '', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'blue_sentry_scripts' );
As you can see, I have declared dependencies for both 'waypoints.min.js' and 'custom.js' of jquery. I believe my code is grammatically correct because all scripts concerned are in fact loading. It's just that Wordpress is ignoring the dependencies enqueueing and loading/executing my custom.js and waypoints.js before jquery is loaded and I have not been able to find a solution!
Any ideas would be greatly appreciated!
Okay, it's working now and here's what I did:
I used:
instead of:
and my problem was solved. This is an example of a fix for a wordpress jquery conflict.