Disable CSS and JS Dashicon files with WPMasterToolKit
WordPress automatically loads Dashicon files (CSS and JS) on every page of your site, even when they're not needed. These files, while useful for the admin interface and logged-in users, add unnecessary requests for offline visitors, which can slow down your site. The module Disable Dashicons CSS and JS files from WPMasterToolKit lets you disable these files for offline users, optimizing your site's performance.
Why disable Dashicons for visitors?
Dashicons is an icon font used by WordPress in the administration and some extensions. However, it's often not necessary for the front-end of your site. Here's why you might want to disable Dashicons:
- Performance enhancement Each additional HTTP request can slow down page loading, especially on high-traffic sites.
- Optimizing resources : By deleting Dashicons for visitors who are not logged in, you reduce the total weight of your pages.
- Preserving minimalist styles : If your theme or plugins don't use Dashicons on the front-end, there's no need to load these files.
How the Disable Dashicons CSS and JS files module works
The module Disable Dashicons CSS and JS files is designed to identify situations where Dashicons is not needed, and disable it accordingly. Here's how it works:
Deactivation for offline users
- Dashicon CSS and JS files are only removed for visitors who are not logged in. This ensures that administrators or authenticated users continue to benefit from Dashicons in the dashboard.
Dashicons maintained on sensitive pages
- Login pages Dashicons remain active on pages such as
wp-login.php
They depend on it to display icons correctly. - Protected pages If a specific page requires Dashicons (for example, a protected page with a special view), the module leaves them enabled.
Using WordPress hooks
The module uses hooks wp_dequeue_style
and wp_deregister_style
to delete Dashicon files. These actions are applied only when the file is superfluous, avoiding any impact on administration or specific pages.
How to use this module
- Installation : Install and activate the plugin WPMasterToolKit on your WordPress site.
- Module activation Go to the list of modules and activate "Disable Dashicons CSS and JS files".
- Automation Once activated, the module works automatically, disabling Dashicons for offline visitors while maintaining their availability for administrators.
Our technical choices for this module
Targeted approach
We've designed this module to disable Dashicons only when relevant:
- Offline visitors benefit from a faster user experience.
- Logged-in users are not affected, retaining a fully functional dashboard.
Lightweight and efficient
The module uses minimalist code based on native WordPress hooks. This guarantees compatibility with future versions of WordPress while minimizing the impact on site performance.
Enhanced safety
All checks, such as identifying login pages or protected pages, are carried out using secure methods, such as sanitize_text_field
and strpos
.
Conclusion
The module Disable Dashicons CSS and JS files from WPMasterToolKit is an ideal solution for optimizing the performance of your WordPress site. By removing useless Dashicon files for offline visitors, it reduces HTTP requests and speeds up page loading. Try it today and enjoy a faster, more optimized site!