Skip to content

Commit 5110ad9

Browse files
committed
README: honest positioning — when to use SVGInject
Replaced comparison table with clear use cases (CMS, static sites, server-rendered, prototyping). Honest recommendation for React/Vue users to consider framework-native tools.
1 parent 5212ee1 commit 5110ad9

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,20 @@ npm install @iconfu/svg-inject
3939
The injected SVG inherits the `class` from the `<img>`, so your CSS rules apply instantly.
4040

4141

42-
## Why SVGInject?
43-
44-
| | SVGInject | svgr | react-inlinesvg | vue-inline-svg |
45-
|--|-----------|------|-----------------|----------------|
46-
| Bundle size | **~4 KB** | varies | 8 KB | 3 KB |
47-
| Dependencies | **0** | babel, etc. | 1 | 1 |
48-
| Works without a build step | **yes** | no | no | no |
49-
| Framework-agnostic | **yes** | React only | React only | Vue only |
50-
| Works with CMS / dynamic HTML | **yes** | no | no | no |
51-
| TypeScript types | **built-in** | built-in | built-in | community |
52-
| Built-in sanitization | **yes** | n/a (build time) | no | no |
53-
| Accessible (ARIA, role) | **automatic** | manual | manual | manual |
54-
55-
SVGInject is the right choice when you want to **style SVGs with CSS without changing your build pipeline** — especially for multi-framework projects, CMS-driven content, or plain HTML sites.
56-
57-
If your project is 100% React and you want compile-time SVG-to-component conversion, [svgr](https://react-svgr.com/) is a great alternative.
42+
## When to use SVGInject
43+
44+
SVGInject works best when you don't have a build step — or don't want one for your SVGs:
45+
46+
- **WordPress, CMS, static sites** — add a `<script>` tag, done
47+
- **Server-rendered pages** — PHP, Rails, Django, any backend template
48+
- **Dynamic / third-party content** — HTML injected at runtime, CMS editors, widgets
49+
- **Prototyping** — style SVGs with CSS without setting up tooling
50+
- **Multi-framework projects** — one solution across jQuery, React, vanilla, whatever
51+
52+
SVGInject is a runtime library. It loads and injects SVGs in the browser. No build step, no bundler, no Node.js required.
53+
54+
**What about React, Vue, Svelte?**
55+
SVGInject works in frameworks too (see [examples below](#frameworks)), but if your project is fully React or Vue, consider framework-native tools like [svgr](https://react-svgr.com/) or [react-inlinesvg](https://github.com/gilbarbara/react-inlinesvg) — they integrate deeper with the component lifecycle (loading states, cleanup, re-rendering).
5856

5957

6058
## Install

0 commit comments

Comments
 (0)