Home > front end >  Dequeue scripts: how to remove font-awesome
Dequeue scripts: how to remove font-awesome

Time:10-19

I've created a child theme. In the parent theme I have found:

function editorial_scripts() {
    wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/library/font-awesome/css/font-awesome.min.css', array(), '4.7.0' );

}
add_action( 'wp_enqueue_scripts', 'editorial_scripts' );

I would like to dequeue the loading of font-awesome. In the child theme I wrote:

function de_script() {
    wp_dequeue_script( 'jquery' );
    wp_deregister_script( 'jquery' );

    // \wp-content\themes\editorial\inc\editorial-functions.php
    wp_dequeue_script( 'font-awesome' );
    wp_deregister_script( 'font-awesome' );
    error_log("here", 0);

}
add_action( 'wp_print_scripts', 'de_script', 100 );

This code has worked, judging by the error log.

But font-awesome is still on the page.

enter image description here

Could you help me?

CodePudding user response:

Your code is using the wrong action. Instead, you want to wp_dequeue_style

function dequeue_font_awesome() {
    wp_dequeue_style( 'font-awesome' );
}
add_action( 'wp_enqueue_scripts', 'dequeue_font_awesome' , 99 );
  • Related