Stop Elementor Icon Fonts Loading for Visitors
Removes the Font Awesome and Elementor icon font stylesheets from the front end for visitors, which saves several requests on sites that use SVG icons or no icons at all.
Opens WPIDE on
Code
// Stylesheet handles to remove. Delete any you still need.
$wpide_el_icon_handles = array(
'font-awesome',
'elementor-icons',
'elementor-icons-shared-0',
'elementor-icons-fa-solid',
'elementor-icons-fa-regular',
'elementor-icons-fa-brands',
);
$wpide_el_dequeue_icons = function () use ( $wpide_el_icon_handles ) {
if ( ! class_exists( '\Elementor\Plugin' ) || is_user_logged_in() ) {
return;
}
if ( isset( $_GET['elementor-preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
foreach ( $wpide_el_icon_handles as $handle ) {
wp_dequeue_style( $handle );
}
};
// Head styles and the styles Elementor adds late, while widgets render.
add_action( 'wp_print_styles', $wpide_el_dequeue_icons, 100 );
add_action( 'wp_print_footer_scripts', $wpide_el_dequeue_icons, 1 );
Notes
Only use this if your pages show no icon-font icons; turn on Elementor's "Inline Font Icons" feature first so icons render as SVG.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.