We received the following question about minification of JS and CSS files in our Ask Yoast inbox:
“Why and how should I minify my JS and CSS files?”
Check out the video or read the answer below!
Minify your JS and CSS files
A browser, like any other computer program, doesn’t care what the language that it receives, looks like. It doesn’t need the spacing and the comments and all other stuff, that your developer needs to make sense of it all. He needs the structure to get through the code, however, the browser has no benefit from that.
Stripping all of that down actually makes the file that you send to the user a lot smaller. Because when you minify it, you remove all the extra spaces, all the line breaks, and all the comments. Stripping all that can save up to 30-40%, or even 50% of file size in some cases. There really is no benefit of sending that stuff to the end-users, so minifying saves time and money for everyone.
That’s why you should do it. Good luck!”
If you’re on WordPress, there’s a vast amount of plugins that can help you minify your HTML, CSS and JS files. We generally recommend WPRocket for this and some further improvements to speed up your site.
Read more: DIY: optimize your browser cache »
Ask Yoast series
Check out our must read articles about Site Speed
Your site should be lightning fast. One way of doing that is by reducing HTTP requests. In this post, you'll find out how to do that.
Site speed is important for SEO. In this post we discuss site speed tools and offer some suggestions to increase the speed of your site.
Site speed is everything! Speeding up your site is one of the most beneficial things you can do for your site. Find out how site speed and SEO go together.
Checking your site speed doesn't need to be daunting. This guide gives you the basics, so you know where to start improving your site speed!