@knighted/jsx 1.0.0-alpha.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,19 @@ The Vite config aliases `@oxc-parser/binding-wasm32-wasi` to the vendored copy s
|
|
|
127
127
|
- JSX identifiers are resolved at runtime through template interpolations; you cannot reference closures directly inside the template without using `${...}`.
|
|
128
128
|
- Promises/async components are not supported.
|
|
129
129
|
|
|
130
|
+
## Performance notes vs `htm`
|
|
131
|
+
|
|
132
|
+
[`htm`](https://github.com/developit/htm) popularized tagged template literals for view rendering by tokenizing the template strings on the fly and calling a user-provided hyperscript function. This library takes a different approach: every invocation runs the native `oxc-parser` (compiled to WebAssembly) to build a real JSX AST before constructing DOM nodes.
|
|
133
|
+
|
|
134
|
+
Tradeoffs to keep in mind:
|
|
135
|
+
|
|
136
|
+
- **Parser vs tokenizer** – `htm` performs lightweight string tokenization, while `@knighted/jsx` pays a higher one-time parse cost but gains the full JSX grammar (fragments, spread children, nested namespaces) without heuristics. For large or deeply nested templates the WASM-backed parser is typically faster and more accurate than string slicing.
|
|
137
|
+
- **DOM-first rendering** – this runtime builds DOM nodes directly, so the cost after parsing is mostly attribute assignment and child insertion. `htm` usually feeds a virtual DOM/hyperscript factory (e.g., Preact’s `h`), which may add an extra abstraction layer before hitting the DOM.
|
|
138
|
+
- **Bundle size** – including the parser and WASM binding is heavier than `htm`’s ~1 kB tokenizer. If you just need hyperscript sugar, `htm` stays leaner; if you value real JSX semantics without a build step, the extra kilobytes buy you correctness and speed on complex trees.
|
|
139
|
+
- **Actual size** – the published `dist/jsx.js` bundle for `@knighted/jsx` is ~13.9 kB uncompressed and ~3.6 kB min+gzip (as of v1.0.0-alpha.0). `htm` weighs in at roughly 0.7 kB min+gzip. Expect the parser-powered approach to add ~3 kB over `htm` in production payloads.
|
|
140
|
+
|
|
141
|
+
In short, `@knighted/jsx` trades a slightly larger runtime for the ability to parse genuine JSX with native performance, whereas `htm` favors minimal footprint and hyperscript integration. Pick the tool that aligns with your rendering stack and performance envelope.
|
|
142
|
+
|
|
130
143
|
## License
|
|
131
144
|
|
|
132
145
|
MIT © Knighted Code Monkey
|