There's a similar question here but I think it's for <img> tags. I'm not really sure if it's the same with background-image.
I'm making a responsive website and my issue is that I do not want images to load if it's accessed through mobile phones (or if it has a small window width). If the image is just applied with a display: none; if using @media, I think there would be wasted time and resources if the image is loaded anyway regardless if it's displayed on mobile phones.
What I need is for images (an <img> or an element with a background-image) to only load if it's visible. I'm kinda concerned of somehow optimizing the responsiveness of my site.
If it's done with javascript (or jQuery), it's nice if it's really lightweight. Thanks!