Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC - HTML minification is it worth it?

http://cestdumeleze.net/blog/2011/minifying-the-html-with-asp-net-mvc-and-razor/

This sounds like a reasonable way to minify HTML; My question is if this could be worth it, or if it introduces problems..

Are any potential performance issues I should know about?

I already minify/gzip all of my css/js

like image 779
bevacqua Avatar asked Feb 21 '12 19:02

bevacqua


Video Answer


2 Answers

Imho, it's a classic case of premature optimization. It won't create problems if done correctly but there are some issues that make it, well, not such a big deal. Nobody uses dialup speeds anymore, not even mobile users, so saving up 1ms makes not that much difference. Furthermore, most web platforms now actively employ gzip over http so your page will already be transparently compressed making this effort all the more unnecessary.

Now, someone is bound to tell that there is no such thing as over-optimizing things, I just beg to differ. Especially if I have to pay someone to do it :)

like image 120
mmix Avatar answered Oct 03 '22 15:10

mmix


I personally wouldn't bother. Whitespace makes up a small very small amount of HTML, and if this is being done at runtime you're going to incur a performance hit just doing the minification. (Javascript, on the other hand, can benefit much more since lines of code tend to be short, and the compiler can shorten variable names considerably.)

If you're looking to improve page load time and you've already minified CSS and JS, try hosting your static content from a CDN and/or setting appropriate Expires headers on your content. That can actually make a substantial difference.

like image 20
Hank Avatar answered Oct 03 '22 16:10

Hank