गाइड

Base64 image और data URL: कब उपयोग करें, कब नहीं

Data URL छोटे file के लिए ठीक है, पर size, cache और performance पर असर डालता है।

क्या करता है

Data URL छोटे file को URL string के अंदर रखता है। Image में आम रूप data:image/png;base64, से शुरू होता है।

अच्छा उपयोग

Tiny icon, test fixture, simple email image या generated preview के लिए उपयोग करें।

Cost

Base64 3 bytes को 4 characters बनाता है। HTML या CSS बड़ा होता है और browser asset देखने से पहले उसे पढ़ता है।

Limits

MDN length limits और security rules बताता है। Modern browsers phishing risk के कारण data: URL top-level navigation block करते हैं।

Practical rule

सिर्फ छोटे files inline करें जिन्हें source में paste करके पढ़ा जा सके। Normal images और uploads अलग file रहें।

तकनीकी स्रोत