Removing jQuery from footer

I am working with HTML5 Blank and I can’t seem to get jquery to stop being called in wp_footer(). I have tried adding this to the bottom of my functions file:

function theme_slug_dequeue_footer_jquery() {
 wp_dequeue_script( 'jquery' );
}
add_action( 'wp_footer', 'theme_slug_dequeue_footer_jquery', 11 );

with no luck. I also tried:

Read More
if( !is_admin()){
wp_deregister_script('jquery');
wp_dequeue_script('jquery');}

but I still end up with /wp-includes/js/jquery/jquery.js?ver=1.8.3 being called in the footer. What am I doing wrong here?

Related posts

Leave a Reply

2 comments

  1. If your working with a blank theme why don’t you just remove or comment out the wp_enqueue_script('jquery'); in the theme functions.php?

    Otherwise your action hook is wrong, use,

    add_action('wp_print_scripts','theme_slug_dequeue_footer_jquery');
    function theme_slug_dequeue_footer_jquery() {
       wp_dequeue_script('jquery');
    }
    

    This will still load the build in jQuery (I think) in /wp-includes/js/jquery/jquery.js?ver=1.8.3

    To remove all jQuery from the admin & the front end you have to deregister_script, this will break how the admin functions but it will still be usable (no drag and drop, etc).

    add_action('wp_print_scripts','theme_slug_dequeue_footer_jquery');
    function theme_slug_dequeue_footer_jquery() {
            wp_deregister_script('jquery');
            wp_dequeue_script('jquery');
        }
    

    Also for just the front end use (this is the one you should be using):

     add_action('wp_print_scripts','theme_slug_dequeue_footer_jquery');
     function theme_slug_dequeue_footer_jquery() {
           if( !is_admin()){
               wp_dequeue_script('jquery');
           }
    }
    
  2. If you need to call another jQuery version, you could use the noConflict method and you can load them in header or footer with no problem in any order.