本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #3042

svg-inline

できること

このスキルは、HTML やコンポーネントに直接書かれた SVG を確認します。デザインを損なわずにページを速くしたい開発者向けです。

使う場面

  • ✓大きなインライン SVG の図があり、HTML が重くなっているとき。
  • ✓同じアイコンがサイトの多くの場所にコピーされているとき。
  • ✓SVG をインラインにすべきか、別の画像ファイルにできるかをレビューしているとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/svg-inline/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ホームページが遅く、HTML がとても大きいです。直接貼り付けられた大きな SVG のロゴを確認してもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、各インライン SVG のサイズを測り、繰り返し使われていないか、そもそもインラインが必要かを確認します。そのうえで、より小さい方法や外部ファイルの選択肢を提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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

よくある質問

SVG をインラインのままにしてよいのはどんな場合ですか?

個々の部品に CSS のホバーやアニメーションが必要な場合は、インライン SVG が役立つとこのスキルは説明しています。静的な図は通常、img タグで十分です。

どのくらいのサイズから大きすぎるとみなされますか?

最適化後で約1KB未満、できれば500バイト未満に抑えることを勧めています。

このスキルは図を削除しますか?

いいえ。削除ではなく、外部ファイルやスプライトへの移動を提案します。

詳細

作者による元の説明

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

人気

GitHubのスター
75k
ランキング
#3042
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル