For your use case, you can use srcsetwith a width descriptor and attribute sizes.
The attribute srcsetdefines a list of image candidates, and you describe the width of each image in a pixel:
srcset="image-640.jpg 640w, image-980.jpg 980w, image-1240.jpg 1240w, image-1900.jpg 1900w, image-2400.jpg 2400w"
The attribute sizesdescribes how large you want to display this image. Here is an example:
sizes="(min-width: 2400px) 2400px, 100vw"
This means that if you want to display it at 2400pixel in a browser window of 2400 or more, otherwise you want to display it at full width of the viewport.
:
<img
srcset="image-640.jpg 640w, image-980.jpg 980w, image-1240.jpg 1240w, image-1900.jpg 1900w, image-2400.jpg 2400w"
sizes="(min-width: 2400px) 2400px, 100vw />
, , , . , ( , - ), . source, .
<picture>
<source media="(min-width: 1024px)" srcset="desktop.png">
<source media="(min-width: 480px)" srcset="tablet.png">
<source srcset="mobile.png">
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="A photo of London by night">
</picture>
srcset sizes Chrome, Firefox Safari 9 ( 8). Safari 8 IE, polyfill (https://github.com/scottjehl/picturefill https://github.com/aFarkas/respimage).