vuejs /petite-vue
6kb subset of Vue optimized for progressive enhancement
★ 9,685⑂ 398👁 74⑃ 59● 0▤ 0
-2
日增长
9,685
stars
398
forks
74
watchers
59
prs
0
issues
0
releases
README
petite-vue
petite-vue is an alternative distribution of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model as standard Vue. However, it is specifically optimized for "sprinkling" a small amount of interactions on an existing HTML page rendered by a server framework. See more details on how it differs from standard Vue.
- Only ~6kb
- Vue-compatible template syntax
- DOM-based, mutates in place
- Driven by @vue/reactivity
Status
- This is pretty new. There are probably bugs and there might still be API changes, so use at your own risk. Is it usable though? Very much. Check out the examples to see what it's capable of.
- The issue list is intentionally disabled because I have higher priority things to focus on for now and don't want to be distracted. If you found a bug, you'll have to either workaround it or submit a PR to fix it yourself. That said, feel free to use the discussions tab to help each other out.
- Feature requests are unlikely to be accepted at this time - the scope of this project is intentionally kept to a bare minimum.
Usage
petite-vue can be used without a build step. Simply load it from a CDN:
html
{{ count }}
inc
- Use v-scope 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.
- The init attribute tells petite-vue to automatically query and initialize all elements that have v-scope on the page.
Manual Init
If you don't want the auto init, remove the init attribute and move the scripts to end of :
html
PetiteVue.createApp().mount()
Or, use the ES module build:
html
import { createApp } from 'https://unpkg.com/petite-vue?module'
createApp().mount()
Production CDN URLs
The short CDN URL is meant for prototyping. For production usage, use a fully resolved CDN URL to avoid resolving and redirect cost:
- Global build: https://unpkg.com/[email protected]/dist/petite-vue.iife.js
- exposes PetiteVue global, supports auto init
- ESM build: https://unpkg.com/[email protected]/dist/petite-vue.es.js
- Must be used with
Root Scope
The createApp function accepts a data object that serves as the root scope for all expressions. This can be used to bootstrap simple, one-off apps:
html
import { createApp } from 'https://unpkg.com/petite-vue?module'
createApp({
// exposed to all expressions
count: 0,
// getters
get plusOne() {
return this.count + 1
},
// methods
increment() {
this.count++
}
}).mount()
{{ count }}
{{ plusOne }}
increment
Note v-scope doesn't need to have a value here and simply serves as a hint for petite-vue to process the element.
Explicit Mount Target
You can specify a mount target (selector or element) to limit petite-vue to only that region of the page:
js
createApp().mount('only-this-div')
This also means you can have multiple petite-vue apps to control difDiscussions
#256Bug: petite-vue breaks Shopify theme editor when used with settings using "visible_if"1 comments · 2026-04-09#255Reactive object setting. Should this be necessary?1 comments · 2026-03-09#250Browser extensions compliant0 comments · 2025-08-14#249Typescript has hard time finding declaration file for petite-vue2 comments · 2025-05-21#248With respect to nice work at here !!! Can we please stop inventing the wheel again and again ...0 comments · 2025-05-17#246Best approach to methods with auto init1 comments · 2025-01-25#245img src bind undefined inside a v-if guard0 comments · 2024-11-03#244NotebookLM Podcast on PettieVue!0 comments · 2024-09-18