Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

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?

share|improve this question
1  
Just to get you right: don't you want jQuery being enqueued at all, or do you just want it to be enqueued in the header rather than in the footer? –  t f Mar 12 '13 at 3:46
    
Do you know what is enqueuing the script? If you dequeue this, whatever is using it could well stop working. –  s_ha_dum Mar 12 '13 at 3:51
    
@tf I want it gone entirely. s_ha_dum: I'm not sure, but I am fine with that outcome. –  Josh Mountain Mar 12 '13 at 4:13

2 Answers 2

up vote 1 down vote accepted

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');
       }
}
share|improve this answer
    
I tried your last block of code there but 1.8.3 is still being called in the footer :( The reason I wanted to do this was because I need to call an older version of jquery in the header before the main page content loads - maybe there is a better way than dequeueing? –  Josh Mountain Mar 12 '13 at 6:56
    
No, disable plugins and switch to the default theme. –  Wyck Mar 12 '13 at 15:58
    
I see now that other includes in my functions file were calling jquery as a dependency ( this post helped wordpress.stackexchange.com/a/35039/27454 ) but your answer was also very helpful and technically correct based on the limited info I provided so thank you! –  Josh Mountain Mar 12 '13 at 17:26

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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