Skip to content

Commit 8194451

Browse files
authored
Add section on caching to README
1 parent 83e08d3 commit 8194451

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ console.log(html`
153153
// ]
154154
```
155155

156+
### Caching
157+
158+
The default build of `htm` caches template strings, which means that it can return the same Javascript object at multiple points in the tree. If you don't want this behaviour, you have three options:
159+
160+
* Change your `h` function to copy nodes when needed.
161+
* Add the code `this[0] = 3;` at the beginning of your `h` function, which disables caching of created elements.
162+
* Use `htm/mini`, which disables caching by default.
163+
156164
## Example
157165

158166
Curious to see what it all looks like? Here's a working app!

0 commit comments

Comments
 (0)