If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to make images not load on a mobile site?

I know i can use display:none, but the page has a lot of pics. The mobile page has less content and few pics. To load quicker and waste less bandwith i want to pics not to load on a mobile phone.
How can I do that?
Thx for the replu, but i guess i was not clear.
I make one page with responsive design. I have the same html, but to CSS, one for big and one for small screens.
The CSS for small screens makes the page look different, much simpler and easy to read on a mobile screen.
I hide most pics and other superfluous content with display:none.
But it seems that still the images will needlessly load, therefore slowing the site down.
How to stop content from loading if i don't need it?

Last edited by PaulV; 11-29-2013 at 06:04 AM.
Reason: the question was not clear

I'm not exactly sure what you're asking. It sounds like you might have two separate pages. Or that you want one page to appear differently depending upon whether it's being viewed on a mobile device or not. Generally javascript and/or media queries (a type of css) are used for these sorts of things. Javascript can device sniff (read the navigator.userAgent string looking for keywords like 'iphone' and 'android', etc.) and do different things based upon that. Media queries can structure different css dependent upon screen size, so a certain class of images and/or other elements (like ones with text and/or images in them) could be display none at smaller screen sizes.

Display none images generally will not load unless made visible. If that's good enough, media queries would be the way to go. If you need it to be more certain, javascript could actually remove some or all images from the DOM before they load. Or even more foolproof (from the point of view of preventing them from even beginning to load), not insert them unless a non-mobile device is detected.

Making them "not load" is harder than making them load. That is, if you want to use some kind of "if" statement, it would probably be easier to do this on the computer than on the phone. So you can check roughly if (!mobile_device) {...
But as John suggested, having two pages (or stylesheets) would be a better approach. Using Javascript to detect a mobile browser isn't entirely reliable and having images conditionally display could cause other complications on an otherwise unproblematic website.

The whole article is very interesting, and you will probably pick up a load of other useful ideas. Anyway, a link within that page goes to a website that shows test cases for methods to stop images from being downloaded on mobile devices. The full article is here: http://timkadlec.com/2012/04/media-q...o_display_none

The concluding part of the post recommends 2 methods for avoiding image downloads on mobile;

1 - Set an image as a background on a div, and then instead of hiding that div, you hide the div's parent element

...if you use this method, you’ll need to consider alternate options for Internet Explorer 8 and under. Those versions of the browser don’t support media queries, so no image will be applied. Of course, this is simple enough to fix with conditional comments and an IE specific stylesheet.