You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-8Lines changed: 38 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,13 @@
1
1
# petite-vue
2
2
3
-
`petite-vue` is a subset of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model with standard Vue. However, it is specifically optimized for "sprinkling" small amount of interactions on an existing HTML page rendered by a server framework.
3
+
`petite-vue` is an alternative distribution of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model with standard Vue. However, it is specifically optimized for "sprinkling" small amount of interactions on an existing HTML page rendered by a server framework.
4
4
5
-
- 5.5kb min+brotli w/ most non-component features
5
+
-Only 5.5kb
6
6
- DOM-based, mutates in place
7
7
- Driven by `@vue/reactivity`
8
8
9
9
## Usage
10
10
11
-
`petite-vue` has one special directive: `v-scope` that is not present in standard Vue. Use it to mark regions on the page that should be controlled by `petite-vue`:
The `defer` attribute makes the script execute after HTML content is parsed, and `init` tells `petite-vue` to automatically query and initialize all elements that have `v-scope` on the page.
21
+
- Use `v-scope` to mark regions on the page that should be controlled by `petite-vue`.
22
+
- The `defer` attribute makes the script execute after HTML content is parsed.
23
+
- The `init` attribute tells `petite-vue` to automatically query and initialize all elements that have `v-scope` on the page.
24
24
25
25
### Manual Init
26
26
@@ -42,6 +42,17 @@ Or, use the ES modules build:
42
42
<script>
43
43
```
44
44
45
+
### `v-effect`
46
+
47
+
Use `v-effect` to execute inline reactive statements:
48
+
49
+
```html
50
+
<div v-scope="{ count: 0 }">
51
+
<div v-effect="$el.textContent = count"></div>
52
+
<button @click="count++">++</button>
53
+
</div>
54
+
```
55
+
45
56
### Global Data
46
57
47
58
The `createApp` function accepts a data object that serves as the root scope for all expressions. This can be used for simple global state management:
@@ -145,7 +156,19 @@ const html = ({ el, get, effect }) => {
145
156
}
146
157
```
147
158
148
-
## Supported Features
159
+
## Features
160
+
161
+
### `petite-vue` only
162
+
163
+
-`v-scope`
164
+
-`v-effect`
165
+
166
+
### Has Different Behavior
167
+
168
+
-`createApp()` (accepts global state instead of root component)
169
+
- Custom directives
170
+
171
+
### Vue Compatible
149
172
150
173
-`{{ }}` text bindings
151
174
-`v-bind` (including `:` shorthand and class/style special handling)
@@ -159,9 +182,9 @@ const html = ({ el, get, effect }) => {
159
182
-`v-pre`
160
183
-`v-cloak`
161
184
-`reactive()`
162
-
-Custom directives (see above).
185
+
-`nextTick()`
163
186
164
-
## Not Supported
187
+
###Not Supported
165
188
166
189
Some features are dropped because they have a relatively low size/utility ratio in the context of progressive enhancement. If you need these features, you should probably just use standard Vue.
167
190
@@ -176,3 +199,10 @@ Some features are dropped because they have a relatively low size/utility ratio
176
199
-`v-once`
177
200
-`v-is` & `<component :is="xxx">`
178
201
-`v-bind:style` auto-prefixing
202
+
203
+
## Relationship with Alpine
204
+
205
+
- This is indeed addressing a similar scope to Alpine, but aims to be even more minimal.
206
+
-`petite-vue` is less than half the size of Alpine.
207
+
-`petite-vue` has no transition system (maybe this can be an opt-in plugin).
208
+
- Alpine is developing its own ecosystem and likely will diverge more from Vue in the future. `petite-vue` aligns with standard Vue behavior whenever possible, so it's less friction moving to standard Vue if needed. It's intended to cover the progressive enhancement use case where standard Vue is less optimized for nowadays.
0 commit comments