Minify CSS & Combine CSS - How it works?

What do "minify" and "combine" mean? 

Minify

Minification is the process of removing white space and comments from code. This makes the file size smaller, therefore faster to download. Minification alone does not reduce the number of HTTP requests on your site.

Combine

When Combine CSS is enabled, all the CSS files are combined into 1 single CSS file, therefore reducing the number of HTTP requests on your site. Combining is a best practice when your site uses HTTP/1 but not necessarily when using HTTP/2.


How WP Rocket does it

  • WP Rocket searches the HTML of the page and discovers CSS files in link tags. Files must have the .css extension.
  • Inline CSS <style> tags will not be processed, only CSS files.
  • As of WP Rocket 3.7, 3rd party CSS (i.e. CSS hosted on a different domain) is hosted on your domain and processed by both the minify and combine settings. This addresses browser caching warnings from speed testing tools and reduces the number of DNS resolutions needed.
  • The files are processed and the optimized versions are stored in: cache/min/1
  • If you use WordPress multisite, the folder named /1/ will change to reflect the site number.
  • Minified files contain a query string (?ver=) with the last modified timestamp, for cache busting purposes (as of WP Rocket version 3.8.6)
    Original file: https://example.com/wp-content/themes/twentytwenty/style.css?ver=1.5
    Minified file:

    https://example.com/wp-content/cache/min/1/wp-content/themes/twentytwenty/style.css?ver=1614629992

  • Combined files use a random string in the filename each time it's regenerated, for cache busting purposes:
  •   https://example.com/wp-content/cache/min/1/fdc1a8722303a3e43f89c03f746fbfeb.css

  • If only Minify is enabled, the order of the files on the page does not change, we just replace the existing CSS files with their optimized version.
  • If Combine is enabled, the combined file is inserted into the page just before the closing </title> tag.
  • This optimization is only applied on cached or optimized pages.
  • Locally-hosted files loaded via @import will be processed and included in both the minified and combined files (from WP Rocket version 3.8.6)

Some files are automatically excluded

These files will not be processed:

  • Files hosted on a 3rd party domain and loaded via @importwill not be processed.
  • Filenames containing .min - they are already minified. Note that 3rd party files with .min in the filename will still be hosted locally, but not further minified.
  • Files with the data-no-minify tag, 
  • Files with a media type specified as only screen and
  • Files with a media type of anything except screen and all
  • Files with media types reserved for specific screen sizes. Examples:screen AND (max-width: 900px),all AND (min-width: 500px),all not (min-width: 500px)

Improve font loading with font-display:swap

When either minify or minify/combine is active, WP Rocket will automatically apply font-display: swap; to any fonts referred to within CSS files. If those fonts have a different font-display rule defined, they will be updated to use font-display: swap;

This will help improve the PageSpeed recommendation: Ensure text remains visible during webfont load

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.