WordPress Minification: What It Is and How to Do It
In this article, we’re going to introduce you to minification. Then, we’ll show you two of the best plugins to minify your WordPress files.
As your site grows bigger with more tools and content, the number of files can expand to the point of slowing down your site. Speed matters on the internet, so a slow-loading site is a big problem.
What Minification Is (And Why It’s Important)
Every second counts on the internet. As websites become more optimized, people have been primed to expect fast loading times. In fact, almost half of all internet users expect sites to load in two seconds or less.
When a single second delay can result in a 7 percent reduction in conversions, being stuck with a slow site can be a death sentence. Fortunately, there are remedies to help you speed up your site, specifically minification.
The process may sound overly technical on the surface, but it’s very straightforward. It simply involves removing unnecessary characters from the code.
Let’s look at an example. Here’s how a CSS snippet would usually look:
If you were to minify this code, the result might end up looking like this:
If you examine the minified code, you’ll see all of the required information is still there, but that line breaks, spaces, and some characters have been removed. These elements are not necessary for a computer to understand the code and only exist to make the code more readable to humans.
It may not seem like such minor changes would have a big effect, but think about how many lines of code you have running under your site’s hood. Minification can significantly cut down the size of each file, which will, in turn, make your site quicker to load. This is especially true if your site contains a large number of files, scripts, and plugins.
We’re now going to look at two methods you can use to minify code, both manually and with a dedicated plugin.
Fortunately, the tools will all work in the same way. For example, using Clean CSS, you paste your original code into the relevant field and click CSS Minify. You’ll see the results in the other field, ready to copy and paste.
However, we recommend saving both versions of the code separately; otherwise, you risk losing the original code. Of course, the original will be easier to troubleshoot and edit than the minified version.
You should also only use manual minification if you are confident in your coding abilities. If you don’t have a lot of experience, we’d recommend using a WordPress minification plugin instead. We’ll be taking a look at two of the best ones next.
2 Plugins to Help Minify Your WordPress Files
1. Fast Velocity Minify
- Requires minimal configuration and runs automatically in real time.
- Offers extensive options for advanced users.
- Great results and reliable support.
As for the price, Fast Velocity Minify is open-source and completely free.
Autoptimize is one of the more popular minification plugins (for good reason). It will bundle your files together, optimize them, and cache them to create as few requests to the site as possible. While it does offer some additional options, this plugin is ideal for those who want a ‘set and forget’ approach to minification.
- Easy for beginners to grasp.
- Provides additional options for more optimized performance.
- Enables more specific customization using the dedicated API.
The Autoptimize plugin is free, although the developers also provide premium configuration services including personal installation and optimization tailored to your site. These cost €119 and €599 respectively.
How to Minify WordPress Files With a Plugin
Now you’re familiar with the tools available, all that remains to do is to minify your WordPress site’s files. For this example, we’ve chosen to use the Fast Velocity Minify plugin. This is because it’s easy to implement for beginners, while still offering a great deal of optional configuration for advanced users. We even recommend it in our knowledge base!
Once you’ve installed and activated the plugin, you don’t need to do anything else — your site is now ready for minification.
The next time somebody visits your site, the plugin will intercept your files and create a copy of them. It will then group the files to cut down on the number of required requests, then minify the code. These optimized files are then saved in the cache and used whenever the site is accessed again. This means your original files are still saved and unaffected.
If you’re a more experienced user, the plugin does offer some advanced settings. You can access these by going to Settings > Fast Velocity Minify within WordPress.
Among other options, you can disable minification for certain files, exclude specific assets from the process, and determine the cache’s location. Each option is annotated with additional information and recommendations, and you can also refer to the FAQ for more information.