Home Ask Login Register

Developers Planet

Your answer is one click away!

SRD January 2017

JS file not loading on Wordpress site

Apologies, I have literally no idea when it comes to .js stuff; I'm a designer mostly and so far have never needed to use any js.

I'm soon to build a site for a client in Wordpress, and they have a slide-based calculations function that I need to lift from their old site; only trouble being that I will be constructing the site using a different theme, so the functionality needs re-integrating into the new theme.

Trouble is, in testing this I can get the slides to appear, but they don't really do anything - and it seems that the problem is that the associated .js file isn't loading. It's been placed in THEME/assets/js/ where it seems it should be, and I have added the following to functions.php:

wp_enqueue_script( 'rangeslider-js', get_template_directory_uri() . '/assets/js/rangeslider.js', array( 'theme-js' ), '1.0', false);

Can anyone point me in the direction of what I'm doing wrong please? Sorry for my complete amateurness - I hope the above makes sense...!


codiiv January 2017

It may be that maybe jquery is not loaded or that there is a conflict with something else.


function myFunction(){
wp_enqueue_script( 'rangeslider-js', get_template_directory_uri() . '/assets/js/rangeslider.js', array( 'jquery','theme-js' ), '1.0', false);
add_action( 'wp_enqueue_scripts', 'myFunction' );

Post Status

Asked in January 2017
Viewed 2,635 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life