We will show you how to minify JS, CSS, and HTML files. In other words, we will go through some tips that will remove superfluous elements from your website.
What Is Minifying?
Ok, think of it visually. Without minification, your codes occupy several lines that can fill pages and pages. But with minification, you can make fit the essential information even on a single line. ‘No more blah blah,’ if we may say so. In fact, it’s a simple matter of quality over quantity. You don’t need to supercharge your website to make it work better. It’s actually quite the opposite.
All in all, minification is a process that first investigates the text-based components of your website. Once it detects the redundant ones, it sort of rewrites it all in a more filtered and simple fashion.
So How to Minify Your Files?
Before getting started, let us say that we will mainly focus on WordPress options. No bombshell here. WP is still the most used website creation platform, and we bet many of you are using it. So it just makes sense to provide examples through a concrete, real-life scenario, doesn’t it?
You may conduct minification processes mainly via two methods: manually or with a plugin. Let’s see what these are about in more detail.
Don’t take the term ‘manual’ too literally. It doesn’t necessarily mean all the weight will be on your shoulders. Rest assured. There are tools that can accompany you efficiently. Using GTMetrix is one of the ways to go for.
- Enter your website URL, and presto! You will get a list of your files that would be better minified.
- Check the list. You will see three sections called, respectively, ‘minify CSS’ (that is, the CSS files requiring minimization), ‘minify JS,’ and ‘minify HTML.’ Each one will display the related resources that require size reduction and an estimation of the reduction (expressed as a percentage).
- Then click ‘See Optimized Version’ and start downloading the minified versions. Careful here: This is the manual part of the task, and you shouldn’t skip it.
- Last but not least, you need to overwrite the original files, namely those in your web directory. Basically, you will be adding the new minified versions to them. This can be done through an FTP client or a file manager in hPanel.
Another manual alternative consists in using tools such as Minify (available at minifier.org). For instance, one proposes JS minify, and CSS minify services. The usual way here is as follows:
- Start by downloading the target files from your website. Don’t forget to save their copies as a backup.
- Then, copy and paste the file’s content into the dedicated area.
- Finally, you must confirm the changes: Save the code into the downloaded file and upload it to your website directory.
What if you don’t want to spend time with codes? Check out the second method below.
Minification with a Plugin
So here it is for those who tend to prefer more automated processes. WordPress puts several plugins at your disposal. Whether you’re looking for an HTML minifier or a CSS minifier, you’ll probably find your groove there. Want a sample of the à la carte menu?
WordPress Super Minify
A plugin of many talents. Be it for combination, inline caching, or minification. It works like a charm or, to be more exact, as an HTML, JS, and CSS compressor. So it’s naturally also a good companion when it comes to leveraging browser caching.
Already a classic. It doesn’t only minify JS, CSS, and HTML files. It’s also capable of caching them and/or bundling them together. Besides, it can program them in a way to make them load to your convenience, at the time you want. You got it. Definitely a tool likely to make you become a master of website performance.
Merge + Minify + Refresh
An almost all-in-one formula, as indicated by the name. Note that it works only for CSS and JS, though (not HTML). It also allows gzip compression. The minification is done by merging CSS and JS files into groups via WP-Cron. The improvements may not be spectacular in comparison to other plugins. However, this tool is still worth being tested for the diversity of operations it does allow. Indeed, you become able to track several steps of the minification process without much effort.
Better WordPress Minify
A safe bet. As a matter of fact, we always need to make sure that minification won’t spoil our theme and other features on our websites. Thanks to this plugin, no more question marks in that regard. Your website remains ‘recognizable’ (so to speak). Furthermore, the plugin ensures multisite compatibility along with CDN integration. Because what we want is not only to minify JS and other files for the sake of it. We also want efficacy in every other aspect of the site’s functioning.
As we said, this was just a sample. Don’t hesitate to test other available plugins until you find the one that seems the most adapted to your website. Also, if it is complex for you, learn what is CSS used for and what is HTML before jumping to anything else.
So Is Minification a Wise Decision?
Judging from what we’ve seen throughout the article, it appears to be so. When you minify JS, CSS, and HTML files, you save those from unnecessary and redundant elements. This has an undeniably positive impact on load/download time. The same goes for bandwidth usage. Don’t forget that you’re designing your website for others rather than yourself. So even if you feel comfortable with complicated codes yourself, you ought to provide your audience with something more stripped-down. Especially nowadays, no one has extra time or patience to lose on slow-paced websites. The competition is huge, so every single gain in terms of optimization and performance is almost sacred.
Conclusion? Take the bull by the horns right now and offer your site this simple yet necessary makeover.