Do you want to minify files on your WordPress site?
What is Minification and When Do You Need it?
The term ‘minify’ is used to describe a method that makes your website file sizes smaller. It does this by removing white spaces, lines, and unnecessary characters from the source code.
Here is an example of normal CSS code:
After minifying the code it will look like this:
You can minify PHP files too, but minifying it will not improve page load speed for your users. That’s because PHP is a server-side programming language, meaning it runs on servers before anything is sent to the visitor’s web browser.
The advantage of minifying files is improved WordPress speed and performance, since compact files are faster to load.
However, some experts believe that the performance improvement is very small for most websites and not worth the trouble. Minification only removes a few kilobytes of data on most WordPress sites. You can reduce more page load time by optimizing images for the web.
We’ll go over 3 different options you can choose from:
Ready? Let’s get started with our top recommended method.
This method is easier and is recommended for all users. It works regardless of which WordPress hosting you are using.
WP Rocket is the best WordPress caching plugin on the market. It allows you to easily add caching to WordPress and significantly improve website speed and page load times.
For more details, see our tutorial on how to install and set up WP Rocket in WordPress.
Upon activation, you need to visit the Settings » WP Rocket page and switch to the ‘File Optimization’ tab.
From here, you need to check the Minify CSS files option.
WP Rocket will then show you a warning that this could break things on your site. Go ahead and click on the ‘Activate Minify CSS’ button. You can always deactivate this option if it causes any issues with your website.
After that, don’t forget to click on the Save changes button to store your settings.
SiteGround Optimizer is a performance optimization plugin that works on their own platform. It works well with their Ultrafast PHP to improve your site’s loading times.
After that, you need to click on the SG Optimizer menu in your WordPress admin sidebar.
This will take you to SG Optimizer settings.
From here you need to click on the ‘Go To Frontend’ button under ‘Other Optimizations’.
On the next screen, you need to switch on the toggle next to the ‘Minify CSS files’ option.
That’s all! You can now empty your WordPress cache and visit your website to load minified versions of CSS and JS files.
This method is recommended for users who are not on SiteGround and not using WP Rocket.
Upon activation, you need to visit the Settings » Autoptimize page to configure the plugin settings.
After that, you need to scroll down to the CSS Options and check the box next to the ‘Optimize CSS code’ option.
Don’t forget to click on Save Changes button to store your settings.