From b52a6c5673dd84a3003183885ba3e8eb110ee93c Mon Sep 17 00:00:00 2001 From: Carson Gross Date: Fri, 20 Nov 2026 13:04:44 -0700 Subject: [PATCH] rewrite htmx in rust --- rust/Cargo.toml | 12 ++++++++++++ rust/src/lib.rs | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 rust/Cargo.toml create mode 100644 rust/src/lib.rs diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 000000000..bdde83545 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "htmx" +version = "5.0.0-blazingly-fast" +edition = "2024" +description = "htmx, but memory safe" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" +web-sys = { version = "0.3", features = ["Document", "Element", "Window"] } diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 000000000..bd186d034 --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,19 @@ +//! htmx, rewritten in Rust and WebAssembly. +//! +//! Status: 1 of approximately 4,000 functions ported. + +use wasm_bindgen::prelude::*; + +/// Ported from `htmx.js`. 0 percent faster, but now it is safe. +#[wasm_bindgen] +pub fn process(elt: &web_sys::Element) -> Result<(), JsValue> { + // TODO: port the rest of htmx + let _ = elt; + unimplemented!("hypermedia is not yet memory safe") +} + +/// The JavaScript version was 16kb. This one is 2.4mb before `wasm-opt`. +#[wasm_bindgen(start)] +pub fn main() { + web_sys::console::log_1(&"htmx (rust edition) loaded. please stand by.".into()); +}