Why people go through all the pain of minifying JavaScript and CSS files if they can just turn on gzip compression on the web server? This will give the same (or even better) result in traffic preformance.
Does minification give additional benifits?
Should I Minify CSS and JS. Generally, the CSS and JS files of dynamic websites don't change very often so they are considered static files. Therefore, you can minify those CSS and JS files once and keep reusing those minified files.
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.
These characters include whitespaces, line breaks, comments, and block delimiters which are useful for us humans but unnecessary for machines. We minify the files of a website containing CSS, HTML, and Javascript code so your web browser can read them faster.
htaccess file. Then load an html or js file via the server and check the headers for "Content-Encoding", if it says gzip or deflate, it is enabled. You need access to your vhost/server config to globally enable compression. You don't need to prepare your files, they're compressed automatically on request.
You can use gzip (which is usually built into web servers) in combination with Minification. Minification does a lot of additional things that gzip can't, however, like removing comments, renaming long variables to shorter variable names, etc.
The resulting transferred data can be signicantly smaller than simply gzipping the original .js. It depends, obviously, on the source .js.
You can check out Compressorater(http://compressorrater.thruhere.net/). You can throw in your .js and it will minify using a variety of libraries with and without gzip and show you the results. You can see the comparion between simply gzipped and gzipped + minified by the various libraries.
Minifying Javascript and CSS not only zips it but it adds other optimisations that are impossible by zipping.
For example, by minifying you can modify the name of a long variable. All the instances of that variable will then be only one character. Another thing minification does it removing comments. This cannot be done by gzip.
Apart from that minification usually bundles various files into one thereby reducing the amount of requests
Apart from minification you should ALSO use gzip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With