0

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.

1
  • 1
    Take a look at this answer for the correct hooks. Commented Feb 21, 2012 at 16:26

1 Answer 1

4

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' ); } ?> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.