https://github.com/scottjehl/picturefill
http://scottjehl.github.io/picturefill/
picturefill允许web开发人员根据不同的屏幕大小、视口大小、屏幕分辨率等情况提供不同的图片给用户。
<script src="picturefill.js"></script>
<head>
<script>
// Picture element HTML5 shiv
document.createElement( "picture" );
</script>
<script src="picturefill.js" async></script>
</head>
<img srcset="examples/images/image-384.jpg 1x, examples/images/image-768.jpg 2x" alt="…">
<img
sizes="(min-width: 40em) 80vw, 100vw"
srcset="examples/images/medium.jpg 375w,
examples/images/large.jpg 480w,
examples/images/extralarge.jpg 768w"
alt="…">
sizes定义img显示的尺寸
<picture>
<source srcset="examples/images/extralarge.jpg" media="(min-width: 1000px)">
<source srcset="examples/images/art-large.jpg" media="(min-width: 800px)">
<img srcset="examples/images/art-medium.jpg" alt="…">
</picture>
image/bmp
image/xbmp
image/jp2
image/vnd.ms-photo
video/vnd.mozilla.apng
<picture>
<source srcset="examples/images/large.webp" type="image/webp">
<img srcset="examples/images/large.jpg" alt="…">
</picture>
picturefill({
reevaluate: true,
elements: [ document.getElementById( "myImg" ) ]
});