Support » Fixing WordPress » Move all Javascript to footer except jQuery

  • Hi,

    I can move all my Javascript right before the </body> tag using the following code:

    # Move all JS from header to footer
    remove_action('wp_head', 'wp_print_scripts');
    remove_action('wp_head', 'wp_print_head_scripts', 9);
    remove_action('wp_head', 'wp_enqueue_scripts', 1);
    add_action('wp_footer', 'wp_print_scripts', 5);
    add_action('wp_footer', 'wp_enqueue_scripts', 5);
    add_action('wp_footer', 'wp_print_head_scripts', 5);

    but I want to keep Jquery in the head tag because some .js files won’t work with jQuery in the end of the body tag. I tried using the following code but jQuery is still loaded with wp_footer.

    wp_deregister_script('jquery');//deregister current jquery
    wp_register_script('jquery', '', false, '1.4.4', false);

    Any one ever do this or is this even possible? Thanks!

  • The topic ‘Move all Javascript to footer except jQuery’ is closed to new replies.