How to Remove javascript / CSS added by WordPress Theme function?

The functions.php of the your WordPress Theme add some javascript and css files to the web pages with wp_enqueue_script and wp_enqueue_style respectively. If you want to remove these javascript of css files, you can just remove the queuing of these files by deleting those lines directly in the functions.php file. However, if you are using a child theme, things will be a little bit complicated, you need to use the wp_dequeue_script and wp_dequeue_style functions. You need to copy and paste the following block of code into the functions.php file of your child theme.

add_action('wp_enqueue_scripts', 'remove_script_css');

function remove_script_css(){
    wp_dequeue_style( 'default-css' );
    wp_dequeue_script( 'default-js' );

In this example, the css file enqueued by the handlerdefault-css” and the javascript file enqueued by the handler “default-js” will be removed. Change these values to the handlers of the javascript and css files you need to remove. The handlers can be found in the functions.php file of the parent theme by searching with “wp_enqueue_“.



Please login to post comments.

Login thru Twitter / Facebook


Log in with Facebook