Article · 5 December 2022
Petit Vue
Tiny Vue alternative for progressive web sites.
Petit 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
Usage
petite-vue can be used without a build step. Simply load it from a CDN:
<script src="https://unpkg.com/petite-vue" defer init></script>
<!-- anywhere on the page -->
<div v-scope="{ count: 0 }">
{{ count }}
<button @click="count++">inc</button>
</div>
- Use
v-scopeto mark regions on the page that should be controlled bypetite-vue. - The
deferattribute makes the script execute after HTML content is parsed. - The
initattribute tellspetite-vueto automatically query and initialize all elements that havev-scopeon the page.