Psatina: the sprinkle-oriented JavaScript library

What it is
Psatina is a tiny JavaScript library for "sprinkling" dynamic behavior on top of server-rendered templates. It has been reported that the minified Brotli-compressed build is about 1.6 KB (psatina.min.js.br) — small enough that you can paste the minified code straight into an HTML file. The project’s author reportedly built it for leisure, not for speed, and that shows in the design: focused, playful, and deliberately tiny. Who doesn’t love a tool that does one thing well?
How it works
Drop the minified script into your page and use a element with a p:data attribute to bind a data scope. JavaScript expressions go between delimiters [| |] in text nodes or attribute values; use the p:set: prefix when you want to set DOM properties instead of attributes, and p:on: for event wiring. Call update() to reapply bindings — it accepts an optional callback, but you don’t have to mutate data inside it. There are a few niceties: p:init runs when a real element is materialized from a template (it receives element as a variable), p:ref stores a handle to an element in the data object, and nesting p:data scopes (useful with p:for and p:ref) gives you per-item scopes. Developers can import the templateDirectives map to register custom directives; each directive receives a context object with properties about the node and scope.
Why it matters
This isn’t trying to be React, Vue, or even a micro-framework. It’s for progressive enhancement — sprinkle behavior where you need it and leave the rest server-rendered. Need a sprinkle or a full bake? For small apps, prototypes, or places where payload size and simplicity beat reactivity gymnastics, Psatina feels like a breath of fresh air. It’s a reminder that sometimes the right tool is the tiniest one that actually does the job.
Sources: psatina.dz4k.com, Lobsters
Comments