Zero JavaScript
The What framework ships no client-side DOM library — no $, no W(), no widget runtime. You describe behavior with tags and w-* attributes, the server does the work, and the browser swaps in rendered HTML. The framework's own runtime handles the wiring; you write HTML.
Everything is a tag or an attribute
The declarative surface covers the interactivity apps actually need:
- Load & inject HTML —
w-get,w-post,w-target,w-swap(see Client Interactions) - Lazy loading & polling —
<what-fetch>withwhen="visible"orpoll="5s"(see Lazy Loading & Polling) - Mutate state —
w-set(see Sessions) - Live reactivity —
w-bind,w-watchover a WebSocket (see Wired State) - Forms & validation —
w-boost,w-validate,w-confirm(see Form Actions) - Clipboard & theme —
<what-clipboard>and<what-theme-toggle>(below) - Disclosure, accordions, tabs — native
<details>and CSS-only.tab-group, no script at all
Copy to clipboard
Give <what-clipboard> the text (or an element to read from) and a label. The button flashes a w-copied class for styling and can swap its label while copied:
<what-clipboard value="cargo install run-what">Copy</what-clipboard>
<!-- copy from an element: anchor → href, input → value, else text -->
<what-clipboard from="#install-cmd" copied-label="Copied!">Copy command</what-clipboard>
Live:
cargo install run-what
The raw attributes work on any element too: w-clipboard="text", w-clipboard-from="selector", w-copied-label="label".
Theme toggle
One tag. It flips the dark/light class on <html>, persists the choice, and the framework restores it before first paint on the next visit — no flash, no script to write:
<what-theme-toggle/>
<!-- or with your own label -->
<what-theme-toggle class="nav-btn">Switch theme</what-theme-toggle>
Live:
The CSS framework adjusts all semantic tokens (--w-bg, --w-text, --w-border…) for dark mode automatically. The raw attribute form is w-theme-toggle on any element; the saved value lives in localStorage['w-theme'].
Tabs & accordions
No JavaScript needed — tabs are CSS-only (.tab-group) and accordions are native <details>. See Client Interactions.
The escape hatch
Plain <script> tags still work, and scripts inside HTML you inject with w-get/w-post execute after the swap (same-origin only) — useful for third-party embeds, canvas, or maps. The framework also fires events you can listen to: w:load, w:success, w:error, w:theme. But if you're reaching for querySelector and addEventListener to build app behavior, stop — that logic belongs on the server. Render it as HTML and fetch it declaratively: less code, no state to sync, and it works before your script loads.