How to override parent scripts in WordPress child theme

When working with WordPress Child Themes I'm sure you've come across this issue.

How do I remove unnecessary scripts from my Child Theme?

First of all, you should not edit the Parent Theme, for many reasons.

The answer is, deregistering scripts in your functions.php file.

In the example below I wanted to deregister the flexslider script because my Child Theme was not using this feature (always optimize for speed!).


function remove_flexslider()
{
wp_deregister_script( 'flexslider' );
}

add_action( 'wp_print_scripts', 'remove_flexslider' );

More information on wp_deregister_script

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*