How to remove global inline styles in WordPress

As of WordPress 5.9, additional inline code was added to improve duotone styles (CSS and SVG code). Most users probably won’t be using this feature, and the problem is that this adds 311 lines (unminified) of code to every page of your WordPress site.

  • 196 lines of CSS is added before the tag.
  • 115 lines of SVG code is added before the tag.
  • Much of the code utilizes !important; tags, which also isn’t ideal.

This appears to be a mistake, and we hope that this gets resolved/fixed in core. But until then, we have a simple way to remove this unnecessary code. If they do remove or change how this works, we will simply deprecate the feature.

Remove global inline styles in WordPress 5.9

Follow the steps below to remove the global inline styles in WordPress.

Step 1

Click into the Perfmatters plugin settings.

How to remove global inline styles in WordPress
Perfmatters plugin settings

Step 2

Make sure you’re on the “General” tab.

How to remove global inline styles in WordPress
Perfmatters General tab

Step 3

Under the “Options” section, scroll down and toggle on “Remove Global Styles.”

How to remove global inline styles in WordPress
Remove global inline styles

Step 4

Scroll down and click “Save Changes.”

We have seen a few sites that utilize global styles, so it’s always recommended to click around your site after enabling a feature just to confirm everything looks good visually.

声明:本站资源绿色无后门无广告,可放心下载。如无特殊说明或标注,均为本站原创发布,转载请注明出处!