{"id":585,"date":"2016-08-23T00:00:00","date_gmt":"2016-08-23T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/websiteimproving-website-performance-minifying-css-html-and-javascript\/"},"modified":"2024-03-01T21:56:28","modified_gmt":"2024-03-01T21:56:28","slug":"websiteimproving-website-performance-minifying-css-html-and-javascript","status":"publish","type":"post","link":"\/my\/tutorials\/website\/improving-website-performance-minifying-css-html-and-javascript","title":{"rendered":"Minify CSS, HTML, and JavaScript in WordPress: A Comprehensive Guide"},"content":{"rendered":"<p>Wouldn&rsquo;t it be great if your site could perform better, even if it&rsquo;s just a little bit faster? To make such a difference, you should learn about WordPress minify.<\/p><p>In this article, we will explain how to minify CSS, HTML, and JavaScript files in WordPress to ensure the absolute best performance!<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/How-to-Speed-Up-Your-Website-EN.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website-1024x283.png\" alt=\"\" class=\"wp-image-69260\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2022\/11\/eBook-Speed-Up-your-website-1536x425.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2022\/11\/eBook-Speed-Up-your-website-300x83.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2022\/11\/eBook-Speed-Up-your-website-150x41.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2022\/11\/eBook-Speed-Up-your-website-768x212.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2022\/11\/eBook-Speed-Up-your-website.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-why-is-it-important-to-minify-your-files\">Why Is It Important to Minify Your Files<\/h2><p>If you&rsquo;ve ever seen an HTML, CSS, or JavaScript file, chances are you&rsquo;ve noticed that there is a lot of <a href=\"\/my\/tutorials\/website-terminology#Whitespace\">whitespace<\/a> or line breaks. These characters make the code easier to read, but the files containing them will be bigger and slower to load.<\/p><p>That&rsquo;s why WordPress minify is crucial for site owners. The process removes unnecessary whitespace, characters, and lines from the code and produces more compact data.<\/p><p>Although many experts argue that minification makes little difference, we still highly recommend it. You need to squeeze out every bit of optimization that you can get to improve user experience and <a href=\"\/my\/tutorials\/website-speed-test\/\">website speed<\/a>. After all, even a split second matters.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>If you <a href=\"\/my\/wordpress-hosting\">host WordPress<\/a> sites at Hostinger, analyze your website directly through hPanel by using the <a href=\"https:\/\/support.hostinger.com\/en\/articles\/6104420-how-to-analyze-a-website-s-speed-on-hpanel\" rel=\"nofollow noopener\" target=\"_blank\">Page Speed feature<\/a>. It will also provide you with suggestions on how you can improve your website&rsquo;s performance.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-two-simple-ways-to-minify-the-files\">Two Simple Ways to Minify the Files<\/h2><p>You can minify your <a href=\"\/my\/tutorials\/wordpress\">WordPress resources<\/a> manually or use a WordPress minify plugin. Read on to find out which one suits you best.<\/p><h3 class=\"wp-block-heading\" id=\"h-minify-the-files-manually\">Minify the Files Manually<\/h3><p>When we say &ldquo;manually&rdquo;, it doesn&rsquo;t mean that you need to delete the unnecessary characters all by yourself. There are lots of helpful tools that can speed up the process. However, you do need to upload the minified files to your site later, so be mindful when following this guide.<\/p><ol class=\"wp-block-list\">\n<li>Locate the files you want to minify by using <a href=\"https:\/\/gtmetrix.com\/\" target=\"_blank\" rel=\"noopener\">GTMetrix<\/a>. Enter your website&rsquo;s URL, and the tool will show the files that you can optimize. If you want to learn more, check out our article about <a href=\"\/my\/tutorials\/gtmetrix-for-testing-websites-speed\">GTMetrix page speed<\/a>!<br><img decoding=\"async\" width=\"1024\" height=\"670\" class=\"aligncenter wp-image-19027 size-large\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/gtmetrix-minify-tab-1024x670.jpg\" alt=\"Minify Tabs on GTMetrix\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab-1024x670.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab-150x98.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab-300x196.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab-768x503.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab-990x648.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/gtmetrix-minify-tab.jpg 1150w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n\n\n\n<li>Click <strong>See Optimized Version<\/strong> to download the minified versions.<\/li>\n\n\n\n<li>Use an <a href=\"\/my\/tutorials\/how-to-create-ftp-accounts\">FTP client<\/a> to overwrite the original files in your site&rsquo;s directory with the minified versions. Alternatively, you can use <a href=\"\/my\/tutorials\/how-to-use-hostinger-file-manager\/\">hPanel&rsquo;s file manager<\/a>.<\/li>\n<\/ol><p>Alternatively, you can also use Minify Code &mdash; a WordPress minify tool that offers separate CSS, HTML, and JavaScript minifiers:<\/p><ol class=\"wp-block-list\">\n<li>Download the files that you want to minify from your website. Save a copy as a backup.<\/li>\n\n\n\n<li>Copy the content of the file and paste it to the appropriate minifier tool.<br><img decoding=\"async\" class=\"aligncenter wp-image-19028 size-large\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/minify-code-1024x478.jpg\" alt=\"Live examples of Minify Code\" width=\"1024\" height=\"478\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code-1320x616.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code-150x70.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code-300x140.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code-768x359.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code-990x462.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/minify-code.jpg 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n\n\n\n<li>Once it&rsquo;s done, paste the code back into the downloaded file and upload it to your website directory.<\/li>\n<\/ol><p>If you want to avoid dealing with code, check the second method below.<\/p><h3 class=\"wp-block-heading\" id=\"h-use-a-wordpress-minify-plugin\">Use a WordPress Minify Plugin<\/h3><p>Using a WordPress minify plugin is way easier since the tool will minify your files automatically. Here are our best choices to do the job, selected based on their features and ease of use:<\/p><ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/wordpress.org\/plugins\/fast-velocity-minify\/\" target=\"_blank\" rel=\"noopener\">Fast Velocity Minify<\/a> minifies your JavaScript and CSS files by using PHP Minify. What&rsquo;s more, you can even ask the developer to make custom optimization options for the plugin.<br><img decoding=\"async\" width=\"1024\" height=\"330\" class=\"aligncenter wp-image-19029 size-large\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/fast-velocity-minify-1024x330.jpg\" alt=\"Fast Velocity Minify, a WordPress Minify Plugin\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify-1024x330.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify-150x48.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify-300x97.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify-768x247.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify-990x319.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/fast-velocity-minify.jpg 1171w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n\n\n\n<li><a href=\"https:\/\/wordpress.org\/plugins\/bwp-minify\/\" target=\"_blank\" rel=\"noopener\">Better WordPress Minify<\/a> makes sure that minifications will not break your theme and other plugins. Furthermore, the plugin also provides many convenient features such as <a href=\"\/my\/tutorials\/what-is-cdn\">CDN<\/a> integration and multisite compatibility.<br><img decoding=\"async\" width=\"1024\" height=\"220\" class=\"alignnone wp-image-19030 size-large\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/better-wordpress-minify-1024x220.jpg\" alt=\"Better WordPress Minify\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify-1320x284.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify-150x32.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify-300x65.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify-768x165.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify-990x213.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/better-wordpress-minify.jpg 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n\n\n\n<li><a href=\"https:\/\/wordpress.org\/plugins\/wp-super-minify\/\" target=\"_blank\" rel=\"noopener\">WordPress Super Minify<\/a> is a WordPress minify plugin that can minify, combine, and <a href=\"\/my\/tutorials\/website\/improving-website-performance-leveraging-browser-cache\">leverage browser&rsquo;s cache<\/a> of your site files. In addition, it is one of the most straightforward and lightweight tools available for this purpose.<\/li>\n<\/ul><p>Whichever plugin you choose, all you need to do is pick the files you want to minify and the tool will work in the background.<\/p><p>However, since those WordPress minify plugins offer other different features, it would be great if you try them all to see which one gives you the most value.<\/p><h2 class=\"wp-block-heading\" id=\"h-testing-the-changes-after-minification\">Testing the Changes After Minification<\/h2><p>Make sure to check that you&rsquo;ve <a href=\"\/my\/tutorials\/website-optimization\">optimized your site<\/a> to the fullest by using GTMetrix. The tool will score the size of your files and show the unresolved issues.<\/p><p>For instance, our test shows that we got a score of 99 for CSS, with two files that could be furhter improved:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"177\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/css-minify-1024x177.jpg\" alt=\"This is before we minify CSS\" class=\"wp-image-19034\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify-1024x177.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify-150x26.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify-300x52.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify-768x133.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify-990x171.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/css-minify.jpg 1150w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div><p>Once we fixed those problems, we scored a perfect 100:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"121\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/08\/perfect-css-score-1024x121.jpg\" alt=\"We will get the perfect score after we minify CSS\" class=\"wp-image-19035\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score-1024x121.jpg 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score-150x18.jpg 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score-300x35.jpg 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score-768x90.jpg 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score-990x117.jpg 990w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2016\/08\/perfect-css-score.jpg 1147w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a href=\"\/my\/web-hosting\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>WordPress minify is a practical optimization that can boost your website performance. And the best thing is, anyone can do it without a problem.<\/p><p>Let&rsquo;s take a look one more time on how to minify WordPress files:<\/p><ul class=\"wp-block-list\">\n<li><strong>Minify the files manually<\/strong> &mdash; use GTMetrix to download the optimized files or shorten the content by using Minify Code. Then, replace the unedited files on your website&rsquo;s directory with the new one.<\/li>\n\n\n\n<li><strong>Use a WordPress minify plugin<\/strong> &mdash; install one of the plugins that we recommend and adjust the configurations based on your preferences. The tool will handle the rest.<\/li>\n<\/ul><p>After you&rsquo;re done, make sure you get a perfect score on GTMetrix!<\/p><p>Let us know in the comment section if you run into any problems.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Read More About Website Optimization<\/h4>\n                    <p><a href=\"\/my\/tutorials\/enable-gzip-compression\">How to Enable GZIP Compression<\/a><br>\n<a href=\"\/my\/tutorials\/website-cache\">What Is Website Caching and How to Clear It<\/a><br>\n<a href=\"\/my\/tutorials\/what-is-seo\/\">What is SEO<\/a><br>\n<a href=\"\/my\/tutorials\/improving-website-performance-enabling-keep-alive\">How to Enable Keep-Alive<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wouldn&rsquo;t it be great if your site could perform better, even if it&rsquo;s just a little bit faster? To make such a difference, you should learn about WordPress minify. In this article, we will explain how to minify CSS, HTML, and JavaScript files in WordPress to ensure the absolute best performance! Why Is It Important [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/my\/tutorials\/website\/improving-website-performance-minifying-css-html-and-javascript\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Minify CSS, HTML, and JavaScript Files in WordPress","rank_math_description":"WordPress minify is a handy optimization to speed up your site. Click on this article to learn how to minify your WordPress!","rank_math_focus_keyword":"wordpress minify","footnotes":""},"categories":[],"tags":[],"class_list":["post-585","post","type-post","status-publish","format-standard","hentry"],"hreflangs":[],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/comments?post=585"}],"version-history":[{"count":27,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/585\/revisions"}],"predecessor-version":[{"id":105077,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/585\/revisions\/105077"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/media?parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/categories?post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/tags?post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}