Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member jonatec's Avatar
    Join Date
    May 2013
    Posts
    8
    Member #
    36331
    Q. What technique is the most efficient in terms of image load times and performance...?

    Scenario 1.

    Is it to load a different size image by using a media query, as below:

    /* Smartphone */
    @media screen and (max-width: 320px) {
    .img-page-1-img {
    background: url('../images/img-page-1-img-117.jpg') no-repeat;
    width: 117px;
    height: 77px;
    }
    }
    /* Desktop */
    @media only screen and (min-width: 769px) {
    .img-page-1-img {
    background: url('../images/img-page-1-img-234.jpg') no-repeat;
    width: 234px;
    height: 154px;
    }
    }

    OR...

    Scenario 2.

    Load one single large image and use CSS to "stretch" and resize by setting the max-width property..?

    img {
    max-width: 100%;
    }


    Thanks....

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    In this use case, it'd be better to use the media queries. That way, you aren't loading a huge image on mobile. However, using a service like SmushIt to compress your images could negate the difference altogether, depending on how well they compress.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Junior Member jonatec's Avatar
    Join Date
    May 2013
    Posts
    8
    Member #
    36331
    Quote Originally Posted by Ronald Roe, post: 251318, member: 27211
    In this use case, it'd be better to use the media queries. That way, you aren't loading a huge image on mobile. However, using a service like SmushIt to compress your images could negate the difference altogether, depending on how well they compress.
    How confident can we be that if there are say, 6 media queries with six different sized images, that the browser won't load all of them, even if the user only open the site from a smartphone?

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    I only just started trying out responsive design a couple of months ago and have only used it on two sites (under development) so I'm by no means an expert on the topic. But if I were you, I'd actually go with option 2 in most circumstances, and here's why:

    1) If the image is that important, it should have an alt attribute. That means you can't use option 1 because CSS backgrounds don't have them. So you'd have to use the larger image (Scenario 2) as a result.

    2) Depending on the target market of your website, there may be people who find content associated with your site using image searches. This is where an img tag with an alt attribute (and other factors such as surrounding content) come into play.

    These are a couple of things you'll need to consider, and a couple of the reasons why your question isn't as cut-and-dried as it may appear.
    jonatec likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Junior Member jonatec's Avatar
    Join Date
    May 2013
    Posts
    8
    Member #
    36331
    Quote Originally Posted by TheGAME1264, post: 251323, member: 428
    I only just started trying out responsive design a couple of months ago and have only used it on two sites (under development) so I'm by no means an expert on the topic. But if I were you, I'd actually go with option 2 in most circumstances, and here's why:

    1) If the image is that important, it should have an alt attribute. That means you can't use option 1 because CSS backgrounds don't have them. So you'd have to use the larger image (Scenario 2) as a result.

    2) Depending on the target market of your website, there may be people who find content associated with your site using image searches. This is where an img tag with an alt attribute (and other factors such as surrounding content) come into play.

    These are a couple of things you'll need to consider, and a couple of the reasons why your question isn't as cut-and-dried as it may appear.

    Excellent answer, thanks !

    It seems if I use max-width: 100%; but keep the image size down and optimised properly for the web, that should do the trick. I never thought of the SEO factor, well done !

  7. #6
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by jonatec, post: 251321, member: 36387
    How confident can we be that if there are say, 6 media queries with six different sized images, that the browser won't load all of them, even if the user only open the site from a smartphone?
    Given properly written media queries,fairly confident: http://timkadlec.com/2012/04/media-q...ading-results/
    Test 5 is particularly relevant to our discussion, as is test 4, though the method in test 4 isn't as good as the one in 5.

    It appears that if the images are set only in media queries, and you take a "mobile first" approach, only one obscure mobile version of FF will download both images.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  8. #7
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Personally I would use media queries just because I like using them and they are slightly less confusing at a larger scale. I also think every designer should know how to use media queries because more and more people are using their phones to browse and personally I'm just not a fan of mobile specific websites.(meaning I don't like it when there are separate versions of websites, one for desktops, one for phones). A am also by no means an expert in any of this but i'm learning.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs




Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:21 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com