How to properly dequeue scripts and styles in child theme?

You are very nearer to the solution, because you are on the right path. Just to tweak a little bit:

There are two such action hooks:

  1. wp_print_scripts, and
  2. wp_print_styles

So the way you can do it, is: hook ’em differently:

//Dequeue Styles
function project_dequeue_unnecessary_styles() {
    wp_dequeue_style( 'bootstrap-map' );
        wp_deregister_style( 'bootstrap-map' );
}
add_action( 'wp_print_styles', 'project_dequeue_unnecessary_styles' );

//Dequeue JavaScripts
function project_dequeue_unnecessary_scripts() {
    wp_dequeue_script( 'modernizr-js' );
        wp_deregister_script( 'modernizr-js' );
    wp_dequeue_script( 'project-js' );
        wp_deregister_script( 'project-js' );
}
add_action( 'wp_print_scripts', 'project_dequeue_unnecessary_scripts' );

And the correct way is to deregister them beside dequeuing. So first dequeue them, and then deregister them accordingly.

Leave a Comment