Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minifying CSS, JS, and HTML - together

Minifying JS and CSS is quite common. The benefits of minifying JS are much greater that those seen with CSS because with CSS you can't rename elements - and same goes for HTML. But what if all 3 were minified together so that the benefits of using shorter names can be brought to CSS and HTML? That is, instead of minifying without any regard to the relationships between the 3, these could be preserved and made simpler. I imagine that the implementation could be quite difficult but if it were possible, do you think it would provide a significant advantage over traditional minification?

like image 510
Radu Avatar asked Dec 28 '10 07:12

Radu


3 Answers

Probably not a significant benefit. If you gzip all your web content, then you will get the benefits of compression without the added complexity of all that minifying. And, you'll compress all the content on your pages too, which is hopefully a significant portion of your page volume.

like image 77
Greg Hewgill Avatar answered Oct 06 '22 11:10

Greg Hewgill


I imagine that the implementation could be quite difficult but if it were possible, do you think it would provide a significant advantage over traditional minification?

Minification does matter and this largely depends on amount of scattered pieces of text. Yahoo's YSlow and Google's Page Speed both do talk about all three and provide solutions such as saving the minified version from within themselves.

So it is good idea to minify where there is room for it and performance is critical.

like image 41
Sarfraz Avatar answered Oct 06 '22 12:10

Sarfraz


Note that using GZIP solves many problems. gzipping responses is efficient if there is a lot of repeated text - for example your css classes. So instead of using a complex minification tool, use gzip.

like image 33
Bozho Avatar answered Oct 06 '22 13:10

Bozho