How To Minify Your Scripts And Stylesheets
Sometimes, these scripts and stylesheets often contain unnecessary data. Thus, it is recommended to minify your scripts and stylesheets. This practice will essentially reduce your file size and improve your website page speed considerably.
What is Minification
Minification is a process of removing unnecessary data from the source code without affecting its functionality. This includes removing white spaces, line breaks, comments, and block delimiters from the original code.
Although minification will remove readability to the code, yet it will also decrease the file size. This will result in faster loading speed since data that need to be transferred is getting smaller. Please take a look at the example below.
For manual minification, I would like to recommend you to use the minifying tool rather than removing it manually by hand. This will decrease the possibility to produce any errors. Besides, there are many online tools that can minify your scripts and stylesheets easily and quickly. Here are some of the free tools available on the internet.
Minify With A Plugin
If you are a WordPress user, you can also minify your scripts and stylesheets by using a plugin. There are several good plugins available in the WordPress directory. Here are some of the best plugins.
Additionally, Autoptimize allows you to remove query strings which will improve your performance score on Pingdom speed test or similar tester. Moreover, you will also have an ability combine your Google Font, remove it or load fonts asynchronously.
Fast Velocity Minify
Similar to the previous plugin, this one also allows you to combine your Google Font with various settings. And on top of that, you can also include any path in the ignore list to prevent it from being optimized.
Merge + Minify + Refresh
In short, by minify your scripts and stylesheets, it will decrease the file size that needs to be download. And by combining these files will decrease your file request. Both of this methods will substantially help you improve your site loading speed. If you have any other ways to minify, please share it with us in the comment section.
He is a web developer, a programmer, and a computer technician. He obsessed with coding and enjoy learning new things. In his spare time, he likes to play online games, musical instruments or watching anime and movies.