DriftJS replaces traditional Virtual DOM tree diffing and Proxy overhead with a compact 256-register virtual machine, build-time bytecode stream, and selective hydration.
pnpm create drift@latestThese interactive components are hydrated selectively using Drift's native Islands Architecture without loading client runtime for the rest of the page.
Test Drift's virtual machine directly in your browser. Edit the code below to see instant in-place DOM updates without VDOM diffing.
Designed for microsecond responsiveness, zero memory churn, and predictable execution.
Executes compact bytecode directly across fixed registers (r0..r255), eliminating recursive stack frames and object allocations during render loops.
State changes trigger microtask updates that re-execute only the exact bytecode instructions bound to dirty variables. Updates patch DOM nodes directly in-place.
Single File Components (.drift) compile at build time into an optimized binary-like bytecode stream and static constant pool, keeping runtime footprints tiny.
Drift Static meta-framework delivers 0 kB JavaScript on static pages, hydrating interactive widgets selectively with client:load, client:visible, and client:idle.
List rendering with @for directive computes the Longest Increasing Subsequence to minimize physical DOM node movements, with fast-path attribute patching.
DriftServerVM renders virtual server node trees to static HTML with comment delimiters (<!--if-->, <!--for-->), claiming DOM nodes efficiently on client hydration.
Write clean components combining JavaScript logic, declarative directives, and scoped styling.
<script>
let count = 0;
const double = derive(() => count * 2);
function inc() {
count++;
}
</script>
<section class="counter">
<h2>Count: {count} (Double: {double})</h2>
<button onclick={inc}>Increment</button>
@if count > 10 {
<p class="milestone">Milestone reached!</p>
}
</section>// Bytecode Stream (Uint32Array)
0x01, r0, "section" // CREATE_ELEMENT
0x05, r0, "class", "counter" // SET_ATTR
0x01, r1, "h2" // CREATE_ELEMENT
0x07, r2, fn(scope.count) // INTERPOLATE_TEXT [PC: 6]
0x04, r1, r2 // APPEND_CHILD
0x04, r0, r1 // APPEND_CHILD
0x01, r3, "button" // CREATE_ELEMENT
0x05, r3, "onclick", fn // SET_ATTR (Event handler)
0x0D, r0, cond, subMod, deps // REACTIVE_IF
0x00, r0 // RETURN