petite-vue

6kb subset of Vue optimized for progressive enhancement

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:

  1. ``` html
  2. <script src="https://unpkg.com/petite-vue" defer init></script>
  3. <div v-scope="{ count: 0 }">
  4.   {{ count }}
  5.   <button @click="count++">inc</button>
  6. </div>
  7. ```

- 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 ``:

  1. ``` html
  2. <script src="https://unpkg.com/petite-vue"></script>
  3. <script>
  4.   PetiteVue.createApp().mount()
  5. </script>
  6. ```

Or, use the ES module build:

  1. ``` html
  2. <script type="module">
  3.   import { createApp } from 'https://unpkg.com/petite-vue?module'
  4.   createApp().mount()
  5. </script>
  6. ```

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/petite-vue@0.2.2/dist/petite-vue.iife.js
  - exposes PetiteVue global, supports auto init
- ESM build: https://unpkg.com/petite-vue@0.2.2/dist/petite-vue.es.js
- Must be used with `