WordPress Made Easy

How to Minify CSS / JavaScript Files in WordPress

Do you wish to minify CSS / Javascript files in WordPress?

WordPress CSS and JavaScript files may be minified to make them load quicker and increase the performance of your WordPress site.

We’ll teach you how to minify CSS/JavaScript files in WordPress to boost efficiency and speed in this post.

WordPress makes it simple to minify CSS and JavaScript files.

What is minification and when is it required?

The term’minify’ refers to a technique for reducing the amount of your website’s files. It does this by deleting extraneous characters, lines, and white spaces from the original code.

Here’s an example of standard CSS:

body {
h1 {

The code will look like this once it has been minified:


Only minifying files that are transmitted to users’ browsers is usually advised. HTML, CSS, and JavaScript files are all included.

You may also minify PHP scripts, however, this will have no effect on page load speed for your visitors. PHP is a server-side programming language, which means it operates on servers before anything is transmitted to the visitor’s web browser.

The benefit of minifying files is that they load quicker, which improves WordPress speed and performance.

However, other experts argue that the performance gain for most websites is insignificant and not worth the effort. On most WordPress sites, minification merely reduces a few kilobytes of material. By optimizing pictures for the web, you may minimize the time it takes for a website to load.

If you’re attempting to get a perfect score on Google Pagespeed or the GTMetrix tool, minifying CSS and JavaScript will help you get there.

After that, let’s look at how to quickly minify CSS and JavaScript on your WordPress site.

Method 1: Use WP Rocket to minify CSS/JavaScript in WordPress

This technique is simpler and should be used by all users. It works no matter which WordPress hosting service you choose.

The WP Rocket plugin must first be installed and activated. See our step-by-step guide on installing a WordPress plugin for more information.

WP Rocket is the most effective WordPress caching plugin available. It makes it simple to add caching to WordPress and boost website performance and page load times dramatically.

See our article on how to install and configure WP Rocket in WordPress for more information.

After activating WP Rocket, go to Settings » WP Rocket and choose the ‘File Optimization’ option.

WP Rocket allows you to minify CSS files.

You must tick the Minify CSS files option from here.

WP Rocket will then display a warning that this may cause issues with your site. Click the ‘Activate Minify CSS’ button to get started. If this feature creates any trouble with your website, you can easily disable it.

CSS minify should be enabled.

After that, scroll down to the JavaScript Files section at the bottom of the page.

Simply choose the ‘Minify JavaScript files’ option and click the box.

WP Rocket reduces the size of JavaScript files.

You’ll receive a warning that this may cause problems on your site once again. Click the ‘Activate Minify JavaScript’ button to get started.

After that, don’t forget to save your changes by clicking the Save changes option.

Your CSS and JavaScript files will now be minified by WP Rocket. You may erase your cache in the plugin settings to ensure that the next website visitor sees the minified CSS and JavaScript.

Method 2: Use SiteGround to minify CSS/JavaScript in WordPress

If you use SiteGround as your WordPress hosting provider, you may use SiteGround Optimizer to minify CSS files.

The SiteGround Optimizer plugin is a performance optimization tool that runs on their own platform. It works great with their Ultrafast PHP to speed up the loading of your site.

On your WordPress site, just install and activate the SiteGround Optimizer plugin. See our step-by-step guide on installing a WordPress plugin for more information.

After that, go to your WordPress admin sidebar and click on the SG Optimizer menu.

SG Optimizer is a program that improves the performance of your

This will lead you to the options for SG Optimizer.

From here, go to ‘Other Optimizations’ and click the ‘Go To Frontend’ button.

Frontend optimization using SiteGround

On the next page, enable the toggle next to the ‘Minify CSS files’ option.

In SiteGround, you may minify CSS.

Switch oma tili to the JavaScript tab and enable the toggle next to the ‘Minify JavaScript Files’ option.

That concludes our discussion. You may now browse your website and load minified versions of CSS and JS files by clearing your WordPress cache.

Method 3: Use Autoptimize to minify CSS/JavaScript.

This option is advised for those who are not using WP Rocket and are not on SiteGround.

The Autoptimize plugin must first be installed and activated. See our step-by-step guide on installing a WordPress plugin for more information.

To adjust the plugin settings, go to Settings » Autoptimize once it’s been activated.

To get started, go to JavaScript Options and tick the option ‘Optimize JavaScript Code.’

JavaScript settings that auto-optimize

Then, scroll down to the CSS Options section and tick the box next to the ‘Optimize CSS code’ option.

CSS code that is optimized automatically

Remember to click the Save Changes button to save your changes.

Then, to begin utilizing your minified files, click the Empty Cache button. In WordPress, the plugin may also be used to address render-blocking JavaScript and CSS.

We hope this post was helpful in reducing the size of your WordPress site’s CSS and JavaScript.

Comments are closed.