borismus/srcset-polyfill has 349 GitHub stars and 31 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-22 19:48 UTC. Last push 2017-03-20.
計測したスター増加
- 24時間
- 0
- 7日間
- 履歴を収集中
- 15日間
- 履歴を収集中
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
概要
[Warning: not for production code]
開発ツールREADME.md
オリジナルWARNING: This project is no longer maintained.
Please use https://github.com/scottjehl/picturefill instead.
A spec-compatible, unit-tested polyfill for <img srcset>
See the specification for the reference algorithm.
Usage
Use the srcset attribute of <img> elements. For example:
<img alt="The Breakfast Combo"
src="banner.jpeg"
srcset="banner-HD.jpeg 2x, banner-phone.jpeg 100w,
banner-phone-HD.jpeg 100w 2x"/>
Include build/srcset.min.js in your page.
Open questions
- How to reliably check for srcset support in the browser (so as to not attempt to polyfill if it's not necessary?)
- Is it safe to use
-webkit-transformto scale things? - Is it worth falling back to
-webkit-image-setif available?
Using srcset-polyfill to reduce bandwidth for mobile devices
If you are wanting to serve smaller images to mobile devices to reduce bandwidth it is important to set your syntax correctly to avoid downloading the mobile optimised image and the original (larger) image. The correct syntax to use is:
<img src="small.jpg" srcset="small.jpg 320w, medium.jpg 960w, large.jpg" />
Notes
- Include the smallest image in the
srcattribute (in the above example:small.jpg). - Include the smallest image and its associated max viewport width in the
srcsetattribute (in the above example:small.jpg 320w). - Include any other, wider viewport widths in the
srcsetattribute (in the above example:medium.jpg 960w). - Include the full size image in the
srcsetattribute, without any viewport width restriction (in the above example;large.jpg).
関連プロジェクトを探す
読み込み中…