WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a theme name is mytheme in themes/mythem/functions.php I using code:

function remove_scripts() {
add_action('init', 'remove_scripts');

=>but result can't remove all javascript, how to fix it ?

share|improve this question
up vote 2 down vote accepted

You either use the admin_*/wp_print_scripts hook or the admin_*/wp_print_styles hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of 0 for the *_print_scripts hook (there might be function with a name that's hooked in earlier on priority 0).

function wpse61635_remove_all_scripts()
    global $wp_scripts;
    $leave_alone = array(
        // Put the scripts you don't want to remove in here.

    foreach ( $wp_scripts->queue as $handle )
        // Here we skip/leave-alone those, that we added above ↑
        if ( in_array( $handle, $leave_alone ) )

        $wp_scripts->remove( $handle );
add_action( 'wp_print_styles', 'wpse61635_remove_all_scripts', 0 );
share|improve this answer

If the function mytheme_head_scripts used priority while hooking into wp_head then you must set your remove_action with same priority.

Example -

function remove_scripts() {
add_action('init', 'remove_scripts');
share|improve this answer

Your Answer


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.