Skip to content

Commit fb08333

Browse files
improve benchmark
1 parent 53b7eb1 commit fb08333

File tree

1 file changed

+42
-6
lines changed
  • inlang/packages/paraglide/paraglide-js/benchmark

1 file changed

+42
-6
lines changed

inlang/packages/paraglide/paraglide-js/benchmark/README.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,57 @@
11
---
2-
imports:
2+
imports:
33
- https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/packages/paraglide/paraglide-js/benchmark/benchmark-visualization.js
44
---
55

66
# Benchmark
77

8-
This benchmark compares the transfer size of different i18n libraries and their implementations.
8+
This benchmark compares the transfer size of Paraglide JS (a compiler-based i18n library) against i18next (a runtime-based library).
99

10-
The goal is to understand how the size of the library changes with different configurations, such as the number of locales, messages per page, and namespace size.
10+
## Key Takeaways
1111

12-
If you are looking for a feature comparison, check out the [comparison table](/m/gerre34r/library-inlang-paraglideJs/comparison).
12+
### Paraglide ships 3-10x smaller bundles than runtime libraries
1313

14-
💡 **Tip**: Paraglide JS has not reached its final optimizations yet. Tickets like [#88 per locale builds](https://github.com/opral/inlang-paraglide-js/issues/88) or [#354 pruning server side rendered messages](https://github.com/opral/inlang-paraglide-js/issues/354) are yet to be implemented. Pull requests are welcome!
14+
In typical scenarios, Paraglide ships **47-144 KB** vs i18next's **205-422 KB**.
1515

16+
| Scenario | Paraglide | i18next | Difference |
17+
|----------|-----------|---------|------------|
18+
| 5 locales, 100 msgs used, 200 total | 47 KB | 205 KB | **4.4x smaller** |
19+
| 10 locales, 100 msgs used, 200 total | 76 KB | 259 KB | **3.4x smaller** |
20+
| 10 locales, 200 msgs used, 500 total | 144 KB | 422 KB | **2.9x smaller** |
21+
22+
### Tree-shaking makes Paraglide immune to total message count
23+
24+
**Runtime libraries ship all messages in a namespace, even unused ones.** Paraglide only ships messages you actually use on a page.
25+
26+
| Total messages | Messages used | Paraglide | i18next |
27+
|----------------|---------------|-----------|---------|
28+
| 200 | 100 | 47 KB | 205 KB |
29+
| 500 | 100 | 47 KB | 283 KB |
30+
| 1000 | 100 | 47 KB | 414 KB |
31+
32+
Paraglide's bundle size stays constant regardless of how many messages exist in your project—unused messages are tree-shaken away at build time.
33+
34+
Runtime libraries like i18next rely on manual namespacing to reduce bundle size, but namespaces still ship all their messages whether used or not. This means developers must carefully split messages across namespaces, and even then, unused messages within a namespace are still shipped.
35+
36+
### Why Paraglide ships smaller bundles
37+
38+
| Aspect | Paraglide (Compiler) | i18next (Runtime) |
39+
|--------|----------------------|-------------------|
40+
| **Unused messages** | Tree-shaken away | Shipped in bundle |
41+
| **Runtime overhead** | ~300 bytes | ~8-10 KB |
42+
| **Message format** | Compiled to functions | JSON dictionary |
43+
44+
---
45+
46+
For a feature comparison, see the [comparison table](/m/gerre34r/library-inlang-paraglideJs/comparison).
47+
48+
## Interactive Benchmark
49+
50+
Explore the full benchmark data with different configurations:
1651

1752
<benchmark-visualization src="https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/packages/paraglide/paraglide-js/benchmark/benchmark-results.json"></benchmark-visualization>
1853

54+
## Methodology
1955

2056
### What is Being Tested
2157

@@ -40,7 +76,7 @@ Each library is tested in different modes:
4076
- **<compiler-option>**: Mode with a [compiler option](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/compiler-options) that is being tested.
4177
- **i18next**:
4278
- **default**: The default i18next implementation [source](https://www.i18next.com/overview/getting-started#basic-sample).
43-
- **http-backend**: i18next implementation using HTTP backend for loading translations on dmeand [source](https://github.com/i18next/i18next-http-backend).
79+
- **http-backend**: i18next implementation using HTTP backend for loading translations on demand [source](https://github.com/i18next/i18next-http-backend).
4480

4581
### Limitations
4682

0 commit comments

Comments
 (0)