Use when Icon or SVG sprite components fetch sprites.svg repeatedly causing excessive bandwidth, or when asset() is called inside a component render function for a constant URL.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Use when Icon or SVG sprite components fetch sprites.svg repeatedly causing excessive bandwidth, or when asset() is called inside a component render function for a constant URL.
SVG Sprites — prevent repeated fetch loop
Problem
Calling asset() inside the component body recomputes the URL on every render. Since <Icon> is rendered once per icon on the page, each instance triggers a separate fetch to sprites.svg — causing the sprite file to be downloaded repeatedly in a loop instead of once.
// ❌ recomputed on every <Icon> renderfunctionIcon({ id }: Props) {
const spritesUrl = asset("/sprites.svg");
return<svg><usehref={`${spritesUrl}#${id}`} /></svg>;
}
Fix — hoist to module level
// ✅ computed once, shared across all rendersconst spritesUrl = asset("/sprites.svg");
functionIcon({ id }: Props) {
return<svg><usehref={`${spritesUrl}#${id}`} /></svg>;
}
General rule
Any asset() call whose result does not depend on props belongs outside the component.