Post

Jason Miller 🦊⚛
Jason Miller 🦊⚛@_developit·
Please don't import SVGs as JSX. It's the most expensive form of sprite sheet: costs a minimum of 3x more than other techniques, and hurts both runtime (rendering) performance and memory usage. This bundle from a popular site is almost 50% SVG icons (250kb), and most are unused.
Jason Miller 🦊⚛ tweet media
English
82
340
1.9K
0
Jason Miller 🦊⚛
Jason Miller 🦊⚛@_developit·
If importing an SVG is the best thing for you ergonomically, choose a solution that returns a URL for use with <img>, or extracts them into <defs> for use with <use href="#">. Unlike JS, SVGs inlined into HTML are pretty cheap.
English
11
11
207
0
Patrick Smith
Patrick Smith@royalicing·
@_developit If you define them in <defs> do all the SVGs have to be defined inline? One for the defs and then one for each usage?
English
1
0
2
0
Simon Bluhm
Simon Bluhm@AnaestheticsApp·
@_developit What's the best approach to use in web components? I assume <use> won't work as it uses URI fragments. Cloning svg using <template>?
English
1
0
0
0
Felix Becker
Felix Becker@felixfbecker·
@_developit <img> doesn't work with CSS and currentColor for fill. When using React putting it into JSX in React components is the easiest. With code splitting it's not as bad I guess. Is there an easy solution (e.g. bundler-based) for the <use> approach? That would probably be best.
English
0
0
5
0
〠
@tomasdev·
@_developit They are not cheap when they are 3000 elements (tried going this route with an emoji keyboard, font or png sprite is so much better)
English
0
0
1
0
Saulo Veronesi
Saulo Veronesi@sauloveronesi·
@_developit That's interesting for sure. I assume same will apply for any webcomponent event using <svg>?
English
0
0
0
0
Adam Collier
Adam Collier@CollierAdam·
@_developit So if I have an Icon component which has a map of imported icons and renders the SVG based on a name prop. What’s the best solution here when importing the svgs? I’m currently lazy loading the imports but that might not be the best solution 🤷‍♂️
English
0
0
0
130
Paylaş