1

I have a wp javascript, wp-embed.min.js, disabled on my WordPress theme by adding this sample code to my theme's function.php file:

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

function my_deregister_javascript() {
    wp_deregister_script( 'wp-embed' );
}

The problem is that the javascript is disabled everywhere, including in the wp-admin page, and one of the plugins I want to use requires it to work.

Is there a way to disable a specific wordpress javascript only on the live website, but not on wp-admin pages?

Thanks

4

You can do a simple is_admin() check before dequeuing your script like below:

Code:

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

function my_deregister_javascript() {

   if ( !is_admin() )
       wp_deregister_script( 'wp-embed' );
   }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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