Is minifying and combining scripts (and CSS) somewhat of a bandwagon?

I read all the time how extra HTTP requests are bad practice. I also see quite a lot of combining scripts and minifying JavaScript and CSS. Maybe I’m a bit too cynical but I can’t help feeling, for the most part, this is a waste of time and people are just jumping on a bandwagon.

First of all let me make it clear:

  • I understand the benefit of minifying large scripts. E.g. JQuery ~halves in size when minified
  • I don’t work on huge sites, I’m talking about small-to-medium sites
  • I’m not saying my opinion is right, it’s more I’m interested in why some people minify everything

My current qualms are:

  • I think minifying CSS is almost pointless. At most you save a few kb—unless you do it for obfuscation
  • For a small site minifying your site-specific scripts is equally pointless for the same reasons as above
  • Combining oft-used scripts into a single file is a good idea but I’ve seen web developers act in a condascending way about HTTP request yet they have an image gallery on their home page with 20 images—ergo 20 extra HTTP requests. Come on, are they that bad? If you have a decent hoster, I don’t see a problem here

So what do you think? Is minifying and combining scripts (and CSS) somewhat of a bandwagon?

It’s worth remembering that not everyone who accesses your site will have a nice, fast broadband connection. A growing number of people are accessing the net from mobile devices where a good connection is not always guaranteed, and some home users are still on dial-up! For these users, reducing the number of requests and bytes transferred is going to make a difference.

Thanks for that. Maybe I don’t understand HTTP requests but what is the difference between 5 x 10kb requests and 1 x 50kb?

There’s overhead associated with making a request (due to headers, cookies etc). You might find this article interesting: http://www.phpied.com/reducing-the-number-of-page-components/

That is very interesting to see how the HTTP requests work. Thank you.

Minifying scrips today has a larger sense.

True, there used to be that you had a monolithic jQuery and minifying it was the only way to shave some bytes.

Today, jQuery has a modular version, following AMD API, which means that you can automatically incorporate in the final file exactly how much you need from jQuery and nothing more, not the whole library.

This is huge gain, and combining the modularization break down with minifying, you can imagine how light your whole site feels now.

Here is my perspective for what its worth. I use a phone browser alot and it has the capability of turning of javascript altogether (although it allows javascript enabled page refreshes on “as required” basis.) Because the town I live in has slow mobile broadband I prefer to leave the javascript turned off.

However, I’ve been struck how many websites won’t even allow you to view the web page content without javascript turned on. Usually I vote with my feet and move on to the next in my Google search.

If the web development world was serious about saving bandwith (or loading time) it wouldn’t be serving up banner ads on so many pages nor making their website completely inoperative without javascript in the first place.

A well designed site, in my opinion, is one that will still work with javascript turned off (even if with more limited functionality).

Sent from my XT316 using Tapatalk 2

The only things I tend to minify are 3rd-party javascript libraries that I don’t modify myself. Otherwise, most of the css/javscript files I create aren’t that large as far as filesize goes.

However, I make sure to configure gzip compression in the htaccess file.

If you’re not using all the functionality they have to offer, and most likely you aren’t, you should consider switching to their AMD version. Nowadays all the significant libraries and frameworks have been modularized.

I’ll also add that performance rules such as to minimize HTTP requests are based on research – repeatable, verifiable numbers. And it turns out that of all the things we can do to speed up our pages, reducing the number of HTTP requests is the #1 most important. The reason is because the browser spends more time just waiting for the first byte of the response than it does on downloading the data itself.

See http://developer.yahoo.com/performance/rules.html and http://stevesouders.com/hpws/rules.php