Snippet: Remove Global WP Styles
Removing global WordPress styles might be necessary for specific customization reasons or to streamline your website’s performance. Here are some reasons why you might consider removing them:
- Custom Styling: If you want complete control over the appearance of your website and prefer to create your own custom stylesheets without any interference from WordPress’s default styles, removing global WP styles can be beneficial.
- Performance Optimization: Global WordPress stylesheets contain CSS rules that may not be used on your website, adding unnecessary bloat to your site’s code. Removing these unused styles can improve your site’s loading speed and overall performance, especially on slower connections or devices.
- Avoiding Style Conflicts: Sometimes, WordPress’s default styles may conflict with custom themes or plugins, causing unexpected layout or design issues. Removing global WP styles can help prevent these conflicts and make it easier to debug and maintain your website’s styling.
- Simplifying Maintenance: By removing global WordPress styles, you reduce the complexity of your website’s CSS codebase, making it easier to maintain and update in the future. This can be particularly helpful if you have a large or complex website with multiple customizations.
However, before removing global WordPress styles, it’s essential to carefully consider the implications and thoroughly test your website to ensure that removing these styles doesn’t negatively impact its appearance or functionality. Additionally, if you’re using WordPress themes or plugins that rely on these styles, removing them may break certain features or cause unintended consequences. Always make backups and test thoroughly before making significant changes to your website’s styling.
Add the following PHP code to your custom code within the builder / code plugin.
// Remove Global Styles and SVG Filters from WP 5.9.1 - 2022-02-27 function remove_global_styles_and_svg_filters() { remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' ); remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' ); } add_action('init', 'remove_global_styles_and_svg_filters');