Can Of Code

Removing FontAwesome CSS from footer when using WPBakery

On a recent project I had already included FontAwesome using their Kit setup where the css / webfonts are loaded by their script. The issue I faced was that because I was using WPBakery I was then including FontAwesome twice.

To remove the enqueued FontAwesome css files I added the following to the themes functions.php


add_action('wp_enqueue_scripts', 'canofcode_dequeue_font_awesome_style', 11);
function canofcode_dequeue_font_awesome_style() {
    wp_deregister_style( 'vc_font_awesome_5_shims' );
    wp_dequeue_style( 'vc_font_awesome_5_shims' );
    wp_deregister_style( 'vc_font_awesome_5' );
    wp_dequeue_style( 'vc_font_awesome_5' );
}

 

I found that it doesn’t effect the loading of FontAwesome when editing the page in the backend editor. I struggled to find something like this when Googling so hope it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *