How To Remove Dashicons in WordPress

Dashicons are a library of icons that you can download as a webfont. They are served to your browser on the backend and the frontend. If you’re logged and ever notice the little icons next to “Posts” or “Pages” etc, these are all from the dashicons library.

You may be wondering why you would want to remove Dashicons and the answer is quite simple. Most of the time, you do not need dashicons loading on the frontend of your website (for non-logged in users). For example, if you’ve ever visited a website in incognito mode and used view-source, you’d see the following CSS file.

https://www.sertmedia.com/wp-includes/css/dashicons.min.css?ver=5.3.1

This CSS file is large and bulky. It loads around 30 KB of data. For reference, the CSS file on my homepage is around 34 KB compressed.

In other words, you’re transferring a large chunk of CSS that will likely never be used. Therefore, it’s best to remove it all together. This can improve your load time, especially on mobile devices.

How To Remove Dashicons From Your Frontend

Note: The WordPress Admin bar requires you to load Dashicons in order to function and display properly. Therefore, we are going to be excluding it with a simple check for logged in users.

You can add the following code snippet to the code snippets plugin, functions.php file (of your child theme), or use the plugin at this link.

function sertmedia_remove_dashicons_junk() {
    if ( ! is_user_logged_in() ) {
          wp_dequeue_style('dashicons');
    }
}
add_action( 'wp_enqueue_scripts', 'sertmedia_remove_dashicons_junk' );

Thoughts

When it comes to optimizing your website, you want to make sure you are only loading what is absolutely necessary. Do not load unnecessary scripts or stylesheets and avoid using third party services. This above code snippet can help noticeably improve your load time and reduce the total size of the stylesheet; with minimal work.

If you have any questions about the implementation or if it’s not working for your website, you can send me a message, comment on this post, or email me and we can troubleshoot!

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

5 thoughts on “How To Remove Dashicons in WordPress”

  1. As I’m going through a theme build from scratch, I’m always looking to remove unnecessary styles/scripts from loading. This post was very helpful because I didn’t know that dashicons only got loaded in the dashboard!

    Reply
  2. I added this code but dashicons are still being loaded, I think because my “hamburger menu” icon comes from there. Any suggestions on how to replace the menu icon?

    Reply

Leave a Comment