Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do many sites minify CSS and JavaScript but not HTML? [duplicate]

Possible Duplicate:
Why minify assets and not the markup?

I have seen a lot of sites using minified CSS and JavaScript to increase website response time but I have never seen any sites use minified HTML. Why would you not want your HTML to be minified?

like image 776
Josh Curren Avatar asked Mar 01 '10 22:03

Josh Curren


People also ask

Should you minify CSS and JS?

Now, because minification removes unnecessary characters from these HTML, CSS, and JS files, the size of these files get smaller. This in turn results in faster downloading and faster rendering of these files. Therefore minification can help improve your website speed.

Why should we minify front end codes HTML CSS JavaScript?

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.

How do you minify CSS and JavaScript in HTML?

To minify CSS, try CSSNano and csso. To minify JavaScript, try UglifyJS. The Closure Compiler is also very effective. You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.

Why should you minify your JavaScript scripts before publishing them?

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.


1 Answers

Because if you're doing things properly you're serving HTML gzipped anyway, so the low-hanging fruit of HTML minification - whitespace - isn't all that relevant. There aren't lots of easy targets (e.g. variable names) for minification in HTML, which are present in CSS and JavaScript. Much of the content of HTML is the actual content of the page, which probably can't be minified (and, as others have pointed out, will almost certainly vary more frequently than your CSS or JS).

like image 93
Dominic Rodger Avatar answered Oct 02 '22 18:10

Dominic Rodger