Performance & caching

VSN.js favors small runtime work and caches parsed behaviors to avoid re-parsing.

Behavior caching

Behavior ASTs are cached so repeated mounts don’t re-parse the same source.

Mutation observer

VSN watches the DOM and re-evaluates only affected elements. Debouncing helps avoid thrashing.

Tips

  • Keep behaviors scoped to specific selectors.
  • Avoid heavy work inside on handlers; prefer small functions.
  • Use vsn-get for partial updates rather than full reflows.