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'm trying to deregsiter multiple scripts using the following function.

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
function my_deregister_javascript() {
    if ( !is_page(array('order', 'shopping-cart', 'checkout') ) ) {
    wp_deregister_script( 'tcp_scripts' );
}

How do I use this function to deregsiter multiple scripts?

Thanks in advance.

share|improve this question
1  
Take a look at this answer for the correct hooks. –  kaiser Feb 21 '12 at 16:26

1 Answer 1

First, you're attempting to deregister too late. You need to use wp_enqueue_scripts, rather than wp_print_scripts.

Second, all you need to do is add a call to wp_deregister_script() for each script you need to deregister:

<?php
add_action( 'wp_enqueue_scripts', 'my_deregister_javascript', 100 );
function my_deregister_javascript() {
    if ( !is_page(array('order', 'shopping-cart', 'checkout') ) ) {
        wp_deregister_script( 'tcp_scripts' );
        // If you need to deregister more scripts when
        // this same conditional is true, just add them here
        wp_deregister_script( 'some-script' );
        wp_deregister_script( 'some-other-script' );
    }
    // If you need to deregister other scripts generally,
    // just do so here, outside the conditional:
    wp_deregister_script( 'some-third-script' );
    wp_deregister_script( 'some-fourth-script' );
}
?>
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.