Remove Font Awesome from your WordPress Theme

There are still many themes that automatically load the Font Awesome icons and do not give users the option to prevent this. If you don’t need the icons or prefer to load them locally, disable loading by the theme. Below we explain how this works.

But first, we briefly explain what Font Awesome icons actually are, everyone has surely seen them before.

What is Font Awesome?

Font Awesome is the most widely used toolkit for vector icons that can be easily customized with CSS. You can change the size and color of the icons, add a drop shadow or use animated loading icons, among other things. As the name suggests, according to their own description, the icons look “fantastic” ? In fact, they are a popular style tool to spice up or design a website with icons.

Disable automatic loading of Font Awesome

Reasons to disable automatic loading from a remote server can include performance improvement and, of course, GDPR compliance.

First of all, you should find out which handle the stylesheet is called with. To do this, look in the functions.php of the theme, you should look for the term font-awesome or fontawesome associated with the wp_enqueue_style call

In our theme for the demo, the corresponding rule was

wp_enqueue_style('mh-font-awesome', "//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css", array(), null);

The $handle is therefore mh-font-awesome

In the code reference from wordpress.org you can find more information about the wp_enqueue_style function

Now insert the following code into the functions.php of the child theme to prevent loading:

// Dequeue Styles - Remove Font Awesome from WordPress Theme
add_action( 'wp_print_styles', 'dequeue_font_awesome_style' );
function dequeue_font_awesome_style() {
      wp_dequeue_style( 'mh-font-awesome' );
      wp_deregister_style( 'mh-font-awesome' );
}

You can find more information about the wp_dequeue_style function in the code reference from wordpress.org

 

Delen:

Picture of admin

admin

Laatste berichten

Follow us