srcset
यह क्या करती है
यह स्किल साइट के इमेज टैग जाँचती है, जहाँ srcset और sizes एट्रीब्यूट छूटे हों वहाँ जोड़ती है, और लेआउट से मेल न खाने वाले एट्रीब्यूट ठीक करती है। यह उन वेब बिल्डरों के लिए है जो हर डिवाइस पर इमेज कुशलता से लोड करवाना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप एजेंट से साइट की इमेज हर डिवाइस के लिए सही आकार में लोड करवाएँ।
- ✓जब फ़ोन पर बड़ी डेस्कटॉप इमेज डाउनलोड हों और मोबाइल डेटा वाले विज़िटर पेज धीमा होने की शिकायत करें।
- ✓जब किसी इमेज में srcset हो पर उसका sizes एट्रीब्यूट इमेज के दिखने के तरीके से मेल न खाए।
Skill का लिंक
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/srcset/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी साइट पर फ़ोन पूरी डेस्कटॉप इमेज डाउनलोड करते हैं। क्या आप srcset जोड़ सकते हैं ताकि हर डिवाइस को उपयुक्त आकार मिले?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट लगभग 100 पिक्सल से चौड़ी ऐसी इमेज खोजता है जिनमें srcset नहीं है, और 400, 800 और 1200 पिक्सल जैसे चौड़ाई संस्करण बनाता है। वह srcset सूची और असली लेआउट से मेल खाता sizes एट्रीब्यूट जोड़ता है, और एक fallback src रखता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Use srcset for responsive images
Without srcset, every user—regardless of their device—downloads the same large image. A 1600px hero image served to a 375px mobile display downloads 4x the data needed. The srcset attribute lets browsers choose the optimal file automatically, reducing bandwidth by 50-80% for mobile users with no change to visual quality.
Quick Reference
- Add
srcsetwith width descriptors (400w,800w) to all images wider than ~100px - Always pair
srcsetwidth descriptors with asizesattribute—withoutsizesthe browser assumes100vw - Use density descriptors (
1x,2x) only for fixed-size images like avatars and icons - Keep
srcpointing to a fallback size for browsers that don't supportsrcset
Check
Scan all <img> elements in this codebase. Flag: 1) Any <img> wider than 100px (in CSS or layout) that lacks a srcset attribute. 2) Any <img> with srcset but missing a sizes attribute (necessary for width descriptors). 3) Any <img> using only density descriptors (1x, 2x) where width descriptors (400w, 800w) would be more appropriate. 4) Any srcset that provides only one size (no benefit over plain src). Report each finding with file path and line number.
Fix
For each <img> missing srcset: 1) Generate multiple width variants: typically 400w, 800w, 1200w (add 1600w for full-bleed images). 2) Add srcset listing each variant with its width descriptor. 3) Add a sizes attribute describing actual CSS layout width at each breakpoint. 4) Keep src pointing to a mid-range size (800w) as the fallback. 5) Add width and height attributes if missing. For each image, show the complete corrected HTML including srcset and sizes.
Explain
Explain how srcset and the two descriptor types work. Width descriptors (400w, 800w) describe the intrinsic width of each candidate; the browser combines this with the sizes attribute to calculate which candidate provides the best pixel density for the current viewport. Density descriptors (1x, 2x) are simpler but less flexible—use them only for fixed-size images like avatars and icons. The sizes attribute is critical: without it, the browser assumes 100vw and always downloads the largest candidate even on narrow screens.
Code Review
Review image assets, markup, and delivery configuration related to Use srcset for responsive images. Flag exact files or components where format choice, sizing, or loading behavior violates the rule, and describe how to confirm the fix in DevTools.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
अक्सर पूछे जाने वाले सवाल
sizes क्यों मायने रखता है?
स्किल कहती है कि इसके बिना ब्राउज़र मान लेता है कि इमेज पूरी व्यूपोर्ट चौड़ाई की है, जिससे वह बहुत बड़ी फ़ाइल चुन सकता है।
घनत्व डिस्क्रिप्टर कब इस्तेमाल करें?
स्किल 1x और 2x केवल निश्चित आकार की इमेज, जैसे अवतार और आइकन, के लिए इस्तेमाल करने को कहती है।
क्या इससे पेज का रूप बदलता है?
नहीं। स्किल कहती है कि यह इमेज के दिखने का तरीका बदले बिना डाउनलोड का आकार घटाता है।
जानकारी
लेखक का मूल विवरण
Use when reviewing image assets, markup, and CDN or build transforms related to Use srcset for responsive images. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.
लोकप्रियता
- GitHub स्टार
- 75k
- रैंकिंग में स्थान
- #3034
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
frontendchecklist
75kकमांड-लाइन टूल से फ़्रंटएंड कोड और लाइव पेजों को एक्सेसिबिलिटी, स्पीड, SEO और सिक्योरिटी के 380 से ज़्यादा नियमों से जाँचती है।
frontend-checklist-global
75kफ़्रंटएंड प्रोजेक्ट को Front-End Checklist के सभी 386 नियमों से ऑडिट करती है, और हर मिली समस्या का ठोस समाधान देती है।
404-page
75kजाँचती है कि आपका गुम पेज उपयोगी लिंक देता है और सही 404 स्टेटस लौटाता है, ताकि भटके हुए विज़िटर रास्ता ढूँढ सकें।
about-page
75kजाँचती है कि आपकी साइट पर एक साफ़ About पेज है जो बताता है कि उसे कौन चलाता है, ताकि विज़िटर और सर्च इंजन का भरोसा बढ़े।
मिलती-जुलती skills
gifgrep
394kयह आपके एजेंट को GIF लाइब्रेरी में खोजने, नतीजों का पूर्वावलोकन करने, GIF डाउनलोड करने, और उससे एक फ़्रेम या फ़्रेम्स की शीट निकालने देती है।
meme-maker
394kयह आपके एजेंट को मीम टेम्पलेट चुनने, अपने कैप्शन जोड़ने और मीम को SVG या PNG इमेज के रूप में बनाने देती है।
ios-icon-gen
280kआपके एजेंट को iOS ऐप्स के लिए icons बनाने देता है। यह Apple symbols या दूसरे स्रोतों के आइकन इस्तेमाल करके सही files बनाता है।