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
Pier
Pier@pierbover·
@_developit What if each SVG is a component? Wouldn't tree shaking (mostly) solve this?
English
1
0
12
0
shihabun shakib
shihabun shakib@iamshakibb·
@_developit Just want to know what would be the best way to use svg. Some time i use them as a component. Thank you .
English
1
0
7
0
Josh Wootonn
Josh Wootonn@JoshWootonn·
@_developit Unless of course you are going to animate the SVG or you want the SVG to be themed by your css-in-js's context
English
1
0
5
0
David Alberto Adler
David Alberto Adler@da_adler·
@_developit What about if you have loads of icons, it's quite common to want to modulate the color of the svg icon. Having it as jsx is super convenient! Doing this with URLs would be annoying?
English
2
0
5
0
Garrett Thompson
Garrett Thompson@garrett_codes·
@_developit Thanks for sharing! I'm a bit lost as to *why* it costs 3x more and the performance is bad though. Care to explain?
English
1
0
2
0
Adam Wathan
Adam Wathan@adamwathan·
@_developit Just to be sure I'm understanding, this icon component at the bottom is no worse for the performance of your app than the paragraph component above it right?
Adam Wathan tweet media
English
1
0
36
0
Adam Bradley ⚡️
Adam Bradley ⚡️@adamdbradley·
@_developit We've tried many tactics, but this has been working well for Ionicons @5.5.1/icons/index.mjs" target="_blank" rel="nofollow noopener">unpkg.com/browse/ionicon… So you can import individual icons as datauri strings, use them in an img, or in ion-icon web component which turns it into an actual <svg>. But that's one of a few formats
English
0
0
14
0
Matthew Phillips
Matthew Phillips@matthewcp·
@_developit Haven't tried it but I assume putting them in a <template> in the HTML and cloning from there works?
English
0
0
2
0
Gui
Gui@goenning·
@_developit When using http2, is it still recommended to go with svg sprites (and possibly download unnecessary icons), or would it be better to load each individual svg separately?
English
1
0
1
0
Aftab Alam🔆
Aftab Alam🔆@aftabbuddy·
@_developit I prefer purely CSS based icons CSS.gg nowadays, wherever I can. Re-use shouldn't lead to duplication in the final markup, and if it's there it should be light enough to not penalize the download size much.
English
2
3
55
0
Paylaş