Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.