Skip to content
프로젝트

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.

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

소개

[Warning: not for production code]

개발 도구

README.md

Original

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-transform to scale things?
  • Is it worth falling back to -webkit-image-set if 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 src attribute (in the above example: small.jpg).
  • Include the smallest image and its associated max viewport width in the srcset attribute (in the above example: small.jpg 320w).
  • Include any other, wider viewport widths in the srcset attribute (in the above example: medium.jpg 960w).
  • Include the full size image in the srcset attribute, without any viewport width restriction (in the above example; large.jpg).

관련 프로젝트 살펴보기

불러오는 중…