Langsung ke konten
Skillpedia
Website & UI (frontend)75k Ā· #3042

svg-inline

Fungsinya

Skill ini meninjau grafik SVG yang ditulis langsung di dalam HTML atau komponen. Skill ini cocok untuk developer yang menginginkan halaman lebih cepat tanpa mengorbankan desain.

Kapan dipakai

  • āœ“Saat halaman berisi gambar SVG inline berukuran besar yang membuat HTML menjadi berat.
  • āœ“Saat ikon yang sama disalin ke banyak tempat di situs.
  • āœ“Saat meninjau apakah SVG perlu inline atau bisa menjadi file gambar terpisah.

Link skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/svg-inline/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/svg-inline/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

ā€œHalaman utama saya lambat dan HTML-nya sangat besar. Sebagian isinya adalah logo SVG besar yang ditempel langsung. Bisakah Anda memeriksanya?ā€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent mengukur setiap SVG inline, memeriksa apakah ada yang berulang, dan apakah benar-benar perlu inline. Setelah itu agent merekomendasikan opsi yang lebih kecil atau eksternal.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Manage inline SVG size and complexity

A complex illustration exported from Figma can easily be 50-200KB of SVG markup. Inlined in HTML, it blocks the HTML parser until it is processed, cannot be cached independently, and balloons every page response. Extracting it to an external file allows browser caching and deferred loading. For icon systems, SVG sprites or component libraries avoid duplicating path data across every page.

Quick Reference

  • Only inline SVG when you need CSS hover/animation on individual paths—static SVGs belong in <img> tags
  • Keep inline SVGs under 1KB (ideally under 500 bytes) after SVGO optimisation
  • Reused icons should be SVG sprites or framework components—not copied inline multiple times
  • Run all SVGs through SVGO before inlining to strip editor artefacts

Check

Scan HTML files and React/Vue components for inline <svg> elements. For each inline SVG: 1) Measure its character count—flag any over 1KB (approximately 1000 characters). 2) Check if it is reused in multiple places (should be a component or sprite). 3) Check if SVGO has been run (look for redundant attributes, inline styles that could be CSS classes, or editor comments). 4) Check if the SVG needs to be inline for CSS styling/animation, or if <img src="file.svg"> would suffice. Report each large inline SVG with its size and location.

Fix

For each problematic inline SVG: 1) Large, non-interactive SVG (e.g., illustration): extract to .svg file and reference with <img src="illustration.svg" alt="...">. 2) Reused icon: create an SVG sprite or React component. 3) SVG needing CSS interactivity (hover, animation): keep inline but run through SVGO first—remove editor artefacts, merge paths, remove redundant attributes. 4) For React projects, use SVGR to import SVGs as components—they tree-shake unused SVGs. 5) Show before/after size comparison.

Explain

Explain the trade-offs of inline SVG. Inline SVG allows CSS styling (fill, stroke) and JavaScript animation on individual paths, which external SVG files or <img> elements cannot support. However, large inline SVGs bloat the HTML, delay HTML parser completion, cannot be cached separately from the page, and duplicate markup when used in multiple places. The guidance is: use inline SVG only when you need CSS/JS interactivity; use <img src="file.svg"> or CSS background for static SVGs; use SVG sprites or React components for reused icons.

Code Review

Review image assets, markup, and delivery configuration related to Manage inline SVG size and complexity. 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.

Rule page: https://frontendchecklist.io/rules/images/svg-inline

Pertanyaan umum

Kapan boleh mempertahankan SVG inline?

Skill menyatakan SVG inline berguna jika Anda memerlukan efek hover atau animasi CSS pada bagian tertentu. Grafik statis biasanya lebih cocok di tag gambar.

Berapa ukuran yang dianggap terlalu besar?

Skill menyarankan SVG inline di bawah sekitar 1KB setelah dioptimalkan, dan idealnya di bawah 500 byte.

Apakah skill ini menghapus grafiknya?

Tidak. Skill menyarankan memindahkannya ke file eksternal atau sprite, bukan menghapusnya.

Detail

Deskripsi asli dari pembuat

Use when reviewing image assets, markup, and CDN or build transforms related to Manage inline SVG size and complexity. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.

repo: thedaviddias/Front-End-Checklist

Popularitas

Bintang GitHub
75k
Peringkat
#3042
Lisensi
MIT
Diperbarui
31/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa