0

I want to register jquery.js in the footer, but even with the true parameter it registers in the header.

Here is the code. The other scripts are registered in the footer. Only jquery does not.

function mysite_scripts() {

wp_deregister_script('jquery');

wp_register_script( 'jquery', get_template_directory_uri() . '/js/libs/jquery-3.1.1.min.js', array(), "3.1.1", true );

wp_register_script( 'plugins-script', get_template_directory_uri() . '/js/plugins.js', array( 'jquery' ), false, true );

wp_register_script( 'main-script', get_template_directory_uri() . '/js/main.js', array( 'jquery', 'plugins-script' ), false, true );

wp_enqueue_script( 'main-script' ); 

add_action( 'wp_enqueue_scripts', 'mysite_scripts' );

1 Answer 1

0

This might work for you. try with enqueue instead of registering it.

wp_deregister_script('jquery');

wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/libs/jquery-3.1.1.min.js', array(), "3.1.1", true );
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.