I'm using React to load SVG files to a page. I have two solutions for this:
<svg>
<path d="awfully long data"/>
</svg>
I'm using React to load SVG files to a page. I have two solutions for this:
<svg>
<path d="awfully long data"/>
</svg>
<svg>
<use xlinkHref="path/to/svg.svg#symbolid" />
</svg>
I'm here to ask which is faster? is it even significant? and will it have much of an effect when used alongside React?
Case 1. where you write SVG into page will be slightly faster + it will save you one request. That means it is perfect for critical above the fold content, for first visit.
But in that case, since SVG is part of the document, it is not cached and not reusable across the pages. That means you will loose on performance on repeated visits. User browsing multiple pages, always downloads page including your inline SVG, instead using cached version, as it would in Case 2.
Some useful reading here https://osvaldas.info/caching-svg-sprite-in-localstorage
So after testing both cases, for my system without any network throttling, there is no recordable difference. With network throttling on GPRS the inline is very slightly faster; for me by only 0.1 seconds.