SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,255
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    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.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    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?

  4. #4
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,255
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by DrQuincy View Post
    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-n...ge-components/

  5. #5
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    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-n...ge-components/
    That is very interesting to see how the HTTP requests work. Thank you.

  6. #6
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Addict
    Join Date
    Aug 2013
    Location
    New Zealand
    Posts
    274
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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

  8. #8
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,516
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    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.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  9. #9
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Force Flow View Post
    The only things I tend to minify are 3rd-party javascript libraries that I don't modify myself.
    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.

  10. #10
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,148
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    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
    "First make it work. Then make it better."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •