Ok, So I designed a responsive layout that doesn't show images for very small screen sizes, using media queries and display: none;
.
So far so good. But these images still download on these devices, causing an increase in bandwidth.
What is the proper way to make these images not download on the specified devices?
Any response would be much appreciated!
Two options I can think of:
style
attributes if you like), using either background-image
or :before
/:after
and content
(not supported by IE 6 or 7), and wrap that CSS code in media queries so that it’s only displayed by devices with larger screens.The only accessible solution right now is to wrap the image with <noscript>
tags, then pull the image out later with javascript. Cookies don't work on first page load (HTMLPreloadScanner), nor with CDNs. Browser-sniffing is useless if your images aren't always 100% of the viewport.
The markup is pretty simple as well:
<noscript data-slimmage>
<img src="http://z.zr.io/ri/1s.jpg?width=150" />
</noscript>
Of course, you can make a server-side helper to even abstract this away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With