Jump to content

How to make images not load on a mobile site?


PaulV

Recommended Posts

  • 3 months later...

FYI loading and displaying are not the same thing. When you set display:none; the image will still consume the same bandwith because it must be physically called in browser memory even though it may not appear. For proof of concept the response time between display:block is significantly quicker than creating the image.

 

Now to actually answer your question you can use one of a few options.

 

My personal favorite trick is simply using a background image

@media only screen and (max-device-width: 480px) {    div {        background-image: url('myImageUrl.png');        height: 200px;        width: 400px;    }}<div></div>

However it can be a bit difficult to control the image ideally depending on your markup and events.

 

 

Another way (slighly more dificult however much more dynamic) is to use a javascript event to create an image through the DOM. Sort of like creating a mobile display template.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...