Preact: RFC / Poll: Should preact support SVG right out-of-the-box?

Created on 18 Jun 2016  路  4Comments  路  Source: preactjs/preact

Preact is an open project. Features and priorities are decided based on feedback and suggestions given here and via Twitter or Gitter. I'd like to propose adding a fairly significant new feature, which is to merge SVG support into Preact itself, rather than providing it as a separate preact-svg module. Please take a moment to read the pros and cons I've laid out below, and feel free to suggest more.

There is a native-svg branch with the bundled implementation if you'd like to see how this would work.

| Pros | Cons |
| --- | --- |
| preact-svg is 1.7kb, no longer needed 1 | Preact gets 115 bytes larger 1 |
| <svg> "just works" - no imports / SVG | Preact gets slightly less modular |
| No dirty hacks would be necessary | Tiny performance hit for custom attributes 2 |

* All sizes listed are gzipped (because this is what Preact is optimized for)

1: Meaning this would be a 1.6kb size _reduction_ for anyone using SVG!

2: This only affects custom attributes (eg: data attributes, etc), which are already significantly slower than properties. The performance hit is a single regex match, which I don't even see making a meaningful difference in any of the perf stats I track.

feedback needed help wanted important

Most helpful comment

@developit I think Preact should stay as modular & small as possible but not at the cost of development convenience. A solution without hacks is a good one, I vote for merging SVG into Preact.

All 4 comments

@developit I think Preact should stay as modular & small as possible but not at the cost of development convenience. A solution without hacks is a good one, I vote for merging SVG into Preact.

Agree with @slmgc

Glad to have the input, thanks to you both! I should have also added a pro: this brings preact a little but closer to react, which does support svg by default.

Time to close this one out! Built-in SVG support will be released as of 5.1.0-beta.16.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k15a picture k15a  路  3Comments

kay-is picture kay-is  路  3Comments

kossnocorp picture kossnocorp  路  3Comments

paulkatich picture paulkatich  路  3Comments

nopantsmonkey picture nopantsmonkey  路  3Comments